大地主题解算

白塞尔大地主题解算c#窗口程序

源项目地址:

勒让德大地主题解算: c#窗口程序勒让德大地主题解算

主窗口设计

 代码

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace 白塞尔大地主题解算
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            Form2 F2 = new Form2();
            F2.Show();
        }

        private void button2_Click(object sender, EventArgs e)
        {
            Form3 F3 = new Form3();
            F3.Show();
        }
    }
}

正算窗口

 

算法

 

 

 

 

 

代码

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace 白塞尔大地主题解算
{
    public partial class Form2 : Form
    {
        public Form2()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            double a = 0, b = 0, e_2 = 0, e_dot_2 = 0, B2, L2, A21, rou = 206264.806247096355;
            int pp = 0;
            if (radioButton1.Checked)
            {
                a = 6378245;//椭圆长半轴
                b = 6356863.0187730473;//椭圆短半轴
                e_2 = 0.006693421622966;//椭圆第一偏心率e^2
                e_dot_2 = 0.006738525414683;//椭圆第二偏心率e'^2 
                pp = 1;
            }
            else if (radioButton2.Checked)//
            {
                a = 6378140;//椭圆长半轴
                b = 6356755.2881575287;//椭圆短半轴
                e_2 = 0.006694384999588;//椭圆第一偏心率e^2
                e_dot_2 = 0.006739501819473;//椭圆第二偏心率e'^2 
                pp = 1;
            }
            else if (radioButton3.Checked)//
            {
                a = 6378137;//椭圆长半轴
                b = 6356752.3142;//椭圆短半轴
                e_2 = 0.00669437999013;//椭圆第一偏心率e^2
                e_dot_2 = 0.00673949674227;//椭圆第二偏心率e'^2 
                pp = 1;
            }
            else if (radioButton4.Checked)//
            {
                a = 6378137;//椭圆长半轴
                b = 6356752.3141;//椭圆短半轴
                e_2 = 0.00669438002290;//椭圆第一偏心率e^2
                e_dot_2 = 0.00673949677548;//椭圆第二偏心率e'^2 
                pp = 1;
            }
            else if (pp == 0)
            {
                MessageBox.Show("请选择椭球体", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            double c = a * a / b;
            if (textBox1.Text != string.Empty && textBox2.Text != string.Empty && textBox3.Text != string.Empty &&
                textBox4.Text != string.Empty && textBox5.Text != string.Empty && textBox6.Text != string.Empty &&
                textBox16.Text != string.Empty && textBox17.Text != string.Empty && textBox18.Text != string.Empty && textBox19.Text != string.Empty)
            {
                //转化为弧度制
                double B1 = (Convert.ToDouble(textBox1.Text) + Convert.ToDouble(textBox2.Text) / 60 + Convert.ToDouble(textBox3.Text) / 3600) / 180 * Math.PI;
                double L1 = (Convert.ToDouble(textBox4.Text) + Convert.ToDouble(textBox5.Text) / 60 + Convert.ToDouble(textBox6.Text) / 3600) / 180 * Math.PI;
                double A1 = (Convert.ToDouble(textBox16.Text) + Convert.ToDouble(textBox17.Text) / 60 + Convert.ToDouble(textBox18.Text) / 3600) / 180 * Math.PI;
                double S = Convert.ToDouble(textBox19.Text);
                //计算起点归化纬度
                double W1 = Math.Sqrt(1 - e_2 * Math.Sin(B1) * Math.Sin(B1));
                double sinu1 = Math.Sin(B1) * Math.Sqrt(1 - e_2) / W1;
                double cosu1 = Math.Cos(B1) / W1;
                //计算辅助函数值
                double sinA0 = cosu1 * Math.Sin(A1);
                double cot_sigma1 = cosu1 * Math.Cos(A1)/sinu1;
                double sin2sigma1 = 2 * cot_sigma1 / (cot_sigma1 * cot_sigma1 + 1);
                double cos2sigma1 = (cot_sigma1 * cot_sigma1 - 1) / (cot_sigma1 * cot_sigma1 + 1);

                double k_2 = e_dot_2 * (1 - sinA0 * sinA0);
                double A = b * (1 + k_2 / 4 - 3 * k_2 * k_2 / 64 + 5 * Math.Pow(k_2, 3) / 256);
                double B = b * (k_2 / 8 - k_2 * k_2 / 32 + 15 * Math.Pow(k_2, 3) / 1024);
                double C = b * (k_2 * k_2 / 128 - 3 * Math.Pow(k_2, 3) / 512);
                double alpha = e_2 / 2 + e_2 * e_2 / 8 + Math.Pow(e_2, 3) / 16 - (e_2 * e_2 / 16 + Math.Pow(e_2, 3) / 16) *
                    (1 - sinA0 * sinA0)+ 3 * Math.Pow(e_2, 3) / 128 * Math.Pow(1 - sinA0 * sinA0, 2);
                double beta = (e_2 * e_2 + Math.Pow(e_2, 3)) / 32 * (1 - sinA0 * sinA0) - 
                    Math.Pow(e_2, 3) / 64 * Math.Pow(1 - sinA0 * sinA0, 2);

                //计算球面长度
                double sigma0 = (S - (B + C * cos2sigma1) * sin2sigma1) / A;
                double sin2,cos2,sigma;
               
                sin2 = sin2sigma1 * Math.Cos(2 * sigma0) + cos2sigma1 * Math.Sin(2 * sigma0);
                cos2= cos2sigma1 * Math.Cos(2 * sigma0) - sin2sigma1 * Math.Sin(2 * sigma0);
                sigma = sigma0 + (B + 5 * C * cos2) * sin2 / A;
                

                //计算经度差改正数
                double delta = (alpha * sigma + beta *( sin2 - sin2sigma1)) * sinA0;


                double sinu2 = sinu1 * Math.Cos(sigma) + cosu1 * Math.Cos(A1) * Math.Sin(sigma);
                B2 = Math.Atan(Math.Abs(sinu2 / (Math.Pow(1 - e_2, 0.5) * Math.Pow(1 - sinu2 * sinu2, 0.5))));
                double A21_  = Math.Atan(cosu1 * Math.Sin(A1) / (cosu1 * Math.Cos(sigma) * Math.Cos(A1) - sinu1 * Math.Sin(sigma)));
                A21 =Math.Abs( Math.Atan(cosu1 * Math.Sin(A1) / (cosu1 * Math.Cos(sigma) * Math.Cos(A1) - sinu1 * Math.Sin(sigma))));
                double lambda = Math.Atan(Math.Sin(A1) * Math.Sin(sigma) / (cosu1 * Math.Cos(sigma) - sinu1 * Math.Sin(sigma) * Math.Cos(A1)));
                if (Math.Sin(A1) < 0)
                {
                    if (Math.Tan(lambda) < 0) lambda =  - Math.Abs(lambda);
                    else lambda = Math.Abs(lambda)-Math.PI;
                }
                else
                {
                    if (Math.Tan(lambda) < 0) lambda = Math.PI- Math.Abs(lambda);
                    else lambda =  Math.Abs(lambda);
                }
                L2 = L1 + lambda - delta;
                
                //转换成角度制
                B2 = B2 * 180 / Math.PI;
                L2 = L2* 180 / Math.PI;
                

                if (Math.Sin(A1) < 0)
                {
                    if (Math.Tan(A21_) < 0) A21 = Math.PI - Math.Abs(A21);
                    else A21 = Math.Abs(A21);
                }
                else
                {
                    if (Math.Tan(A21_) < 0) A21 =2*Math.PI - Math.Abs(A21);
                    else A21 =Math.PI+ Math.Abs(A21);
                }

                A21 = A21 * 180 / Math.PI;
                //打印纬度
                textBox7.Text = Convert.ToString(Math.Floor(B2));
                textBox8.Text = Convert.ToString(Math.Floor((B2 - Math.Floor(B2)) * 60));
                textBox9.Text = Convert.ToString(((B2 - Math.Floor(B2)) * 60 - Math.Floor((B2 - Math.Floor(B2)) * 60)) * 60);
                //打印经度
                textBox10.Text = Convert.ToString(Math.Floor(L2));
                textBox11.Text = Convert.ToString(Math.Floor((L2 - Math.Floor(L2)) * 60));
                textBox12.Text = Convert.ToString(((L2 - Math.Floor(L2)) * 60 - Math.Floor((L2 - Math.Floor(L2)) * 60)) * 60);
                //打印A21
                textBox13.Text = Convert.ToString(Math.Floor(A21));
                textBox14.Text = Convert.ToString(Math.Floor((A21 - Math.Floor(A21)) * 60));
                textBox15.Text = Convert.ToString(((A21 - Math.Floor(A21)) * 60 - Math.Floor((A21 - Math.Floor(A21)) * 60)) * 60);
            }
            else
            {
                MessageBox.Show("请输入完整参数", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }

        }

        private void button2_Click(object sender, EventArgs e)
        {
            textBox1.Text = string.Empty;
            textBox2.Text = string.Empty;
            textBox3.Text = string.Empty;
            textBox4.Text = string.Empty;
            textBox5.Text = string.Empty;
            textBox6.Text = string.Empty;
            textBox7.Text = string.Empty;
            textBox8.Text = string.Empty;
            textBox9.Text = string.Empty;
            textBox10.Text = string.Empty;
            textBox11.Text = string.Empty;
            textBox12.Text = string.Empty;
            textBox13.Text = string.Empty;
            textBox14.Text = string.Empty;
            textBox15.Text = string.Empty;
            textBox16.Text = string.Empty;
            textBox17.Text = string.Empty;
            textBox18.Text = string.Empty;
            textBox19.Text = string.Empty;
        }
    }
}

反算窗口

 

算法

 

 

代码

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace 白塞尔大地主题解算
{
    public partial class Form3 : Form
    {
        public Form3()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            double a = 0, b = 0, e_2 = 0, e_dot_2 = 0, A1, S, A21, rou = 206264.806247096355;
            int pp = 0;
            if (radioButton1.Checked)
            {
                a = 6378245;//椭圆长半轴
                b = 6356863.0187730473;//椭圆短半轴
                e_2 = 0.006693421622966;//椭圆第一偏心率e^2
                e_dot_2 = 0.006738525414683;//椭圆第二偏心率e'^2 
                pp = 1;
            }
            else if (radioButton2.Checked)//
            {
                a = 6378140;//椭圆长半轴
                b = 6356755.2881575287;//椭圆短半轴
                e_2 = 0.006694384999588;//椭圆第一偏心率e^2
                e_dot_2 = 0.006739501819473;//椭圆第二偏心率e'^2 
                pp = 1;
            }
            else if (radioButton3.Checked)//
            {
                a = 6378137;//椭圆长半轴
                b = 6356752.3142;//椭圆短半轴
                e_2 = 0.00669437999013;//椭圆第一偏心率e^2
                e_dot_2 = 0.00673949674227;//椭圆第二偏心率e'^2 
                pp = 1;
            }
            else if (radioButton4.Checked)//
            {
                a = 6378137;//椭圆长半轴
                b = 6356752.3141;//椭圆短半轴
                e_2 = 0.00669438002290;//椭圆第一偏心率e^2
                e_dot_2 = 0.00673949677548;//椭圆第二偏心率e'^2 
                pp = 1;
            }
            else if (pp == 0)
            {
                MessageBox.Show("请选择椭球体", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            double c = a * a / b;
            //转化为弧度制
            double B1 = (Convert.ToDouble(textBox1.Text) + Convert.ToDouble(textBox2.Text) / 60 + Convert.ToDouble(textBox3.Text) / 3600) / 180 * Math.PI;
            double L1 = (Convert.ToDouble(textBox4.Text) + Convert.ToDouble(textBox5.Text) / 60 + Convert.ToDouble(textBox6.Text) / 3600) / 180 * Math.PI;
            double B2 = (Convert.ToDouble(textBox7.Text) + Convert.ToDouble(textBox8.Text) / 60 + Convert.ToDouble(textBox9.Text) / 3600) / 180 * Math.PI;
            double L2 = (Convert.ToDouble(textBox10.Text) + Convert.ToDouble(textBox11.Text) / 60 + Convert.ToDouble(textBox12.Text) / 3600) / 180 * Math.PI;
            //计算辅助函数值
            double W1 = Math.Sqrt(1 - e_2 * Math.Sin(B1) * Math.Sin(B1));
            double W2 = Math.Sqrt(1 - e_2 * Math.Sin(B2) * Math.Sin(B2));
            double sinu1 = Math.Sin(B1) * Math.Sqrt(1 - e_2) / W1;
            double sinu2 = Math.Sin(B2) * Math.Sqrt(1 - e_2) / W2;
            double cosu1 = Math.Cos(B1) / W1;
            double cosu2 = Math.Cos(B2) / W2;
            double L = L2 - L1;
            double a1 = sinu1 * sinu2;
            double a2 = cosu1 * cosu2;
            double b1 = cosu1 * sinu2;
            double b2 = sinu1 * cosu2;

            double lambda=L, sigma=0, sinA0, x,lambda0,p,q,delta=0;
            do {

                lambda0 = lambda;
                p = cosu2 * Math.Sin(lambda);
                q = b1 - b2 * Math.Cos(lambda);
                A1 = Math.Atan(p / q);
                if (p < 0)
                {
                    if (q < 0) A1 = Math.PI + Math.Abs(A1);
                    else A1 = 2 * Math.PI - Math.Abs(A1);
                }
                else
                {
                    if (q < 0) A1 = Math.PI - Math.Abs(A1);
                    else A1 = Math.Abs(A1);
                }

                double sin_sigma = p * Math.Sin(A1) + q * Math.Cos(A1);
                double cos_sigma = a1 + a2 * Math.Cos(lambda);
                sigma = Math.Atan(sin_sigma / cos_sigma);
                if (cos_sigma < 0) sigma = Math.PI - Math.Abs(sigma);
                else sigma = Math.Abs(sigma);
             
                sinA0 = cosu1 * Math.Sin(A1);
                x = 2 * a1 - (1 - sinA0 * sinA0) * Math.Cos(sigma);
                double alpha = e_2 / 2 + e_2 * e_2 / 8 + Math.Pow(e_2, 3) / 16 - (e_2 * e_2 / 16 + Math.Pow(e_2, 3) / 16) *
                        (1 - sinA0 * sinA0) + 3 * Math.Pow(e_2, 3) / 128 * Math.Pow(1 - sinA0 * sinA0, 2);
                double beta = (e_2 * e_2 + Math.Pow(e_2, 3)) / 32 * (1 - sinA0 * sinA0) -
                    Math.Pow(e_2, 3) / 64 * Math.Pow(1 - sinA0 * sinA0, 2);
                delta= (alpha * sigma - 2 * beta * x * Math.Sin(sigma)) * sinA0;
                lambda = L + delta;
            } while (Math.Abs(lambda-lambda0)*rou>0.0001);

            double k_2 = e_dot_2 * (1 - sinA0 * sinA0);
            double A = b * (1 + k_2 / 4 - 3 * k_2 * k_2 / 64 + 5 * Math.Pow(k_2, 3) / 256);
            double B = b * (k_2 / 8 - k_2 * k_2 / 32 + 15 * Math.Pow(k_2, 3) / 1024);
            double C = b * (k_2 * k_2 / 128 - 3 * Math.Pow(k_2, 3) / 512);
            double B_ = 2 * B / (1 - sinA0 * sinA0);
            double C_ = 2 * C / Math.Pow(1 - sinA0 * sinA0, 2);

            double y = (Math.Pow(1 - sinA0 * sinA0, 2) - 2 * x * x) * Math.Cos(sigma);
            S = A * sigma + (B_ * x + C_* y) * Math.Sin(sigma);
            double A21_ = Math.Atan(cosu1 * Math.Sin(lambda) / (b1 * Math.Cos(lambda) - b2));
            A21 = Math.Abs(Math.Atan( cosu1 * Math.Sin(lambda) / (b1 * Math.Cos(lambda) - b2) ));
            if (Math.Sin(A1)< 0)
            {
                if (Math.Tan(A21_)< 0) A21 = Math.PI - Math.Abs(A21);
                else A21 = Math.Abs(A21);
            }
            else
            {
                if (Math.Tan(A21_) < 0) A21 = 2*Math.PI - Math.Abs(A21);
                else A21 = Math.PI+ Math.Abs(A21);
            }




            textBox13.Text = Convert.ToString(S);
            //打印A12
            A1 = A1 * 180 / Math.PI;
            textBox19.Text = Convert.ToString(Math.Floor(A1));
            textBox18.Text = Convert.ToString(Math.Floor((A1 - Math.Floor(A1)) * 60));
            textBox17.Text = Convert.ToString(((A1 - Math.Floor(A1)) * 60 - Math.Floor((A1 - Math.Floor(A1)) * 60)) * 60);
            //打印A21
            A21 = A21 * 180 / Math.PI;
            textBox16.Text = Convert.ToString(Math.Floor(A21));
            textBox15.Text = Convert.ToString(Math.Floor((A21 - Math.Floor(A21)) * 60));
            textBox14.Text = Convert.ToString(((A21 - Math.Floor(A21)) * 60 - Math.Floor((A21 - Math.Floor(A21)) * 60)) * 60);


        }

        private void button2_Click(object sender, EventArgs e)
        {
            textBox1.Text = string.Empty;
            textBox2.Text = string.Empty;
            textBox3.Text = string.Empty;
            textBox4.Text = string.Empty;
            textBox5.Text = string.Empty;
            textBox6.Text = string.Empty;
            textBox7.Text = string.Empty;
            textBox8.Text = string.Empty;
            textBox9.Text = string.Empty;
            textBox10.Text = string.Empty;
            textBox11.Text = string.Empty;
            textBox12.Text = string.Empty;
            textBox13.Text = string.Empty;
            textBox14.Text = string.Empty;
            textBox15.Text = string.Empty;
            textBox16.Text = string.Empty;
            textBox17.Text = string.Empty;
            textBox18.Text = string.Empty;
            textBox19.Text = string.Empty;

        }
    }
}

评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值