大地坐标系
空间直角坐标系
子午面直角坐标系文章来源:https://www.toymoban.com/news/detail-738606.html
文章来源地址https://www.toymoban.com/news/detail-738606.html
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 project1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
double L, B, H, X, Y, Z, x, y;
double a = 6378137;//椭圆长半轴
double b = 6356752.3141;//椭圆短半轴
double e_2 = 0.00669438002290;//椭圆第一偏心率e^2
double e_dot_2 = 0.00673949677548;//椭圆第二偏心率e'^2
double c = a * a / b;
double k = 1 + e_dot_2;
double p = Math.PI / 180;//角度值转弧度制系数
//如果需要更严谨的代码,可以更换为三个textbox是否为空的判断,并自行添加参数错误提示的信息
if (textBox5.Text != string.Empty&& textBox4.Text != string.Empty)//已知大地坐标系
{
L = Convert.ToDouble(textBox1.Text);
B= Convert.ToDouble(textBox4.Text);
H= Convert.ToDouble(textBox5.Text);
double W = Math.Sqrt(1 - e_2 * Math.Sin(B*p) * Math.Sin(B * p));
double V = Math.Sqrt(1 + e_dot_2 * Math.Cos(B * p) * Math.Cos(B * p));
double N = a / W;
//计算空间直角坐标系
X = (N+H)*Math.Cos(B * p) * Math.Cos(L * p);
Y = (N + H) * Math.Cos(B * p) * Math.Sin(L * p);
Z = (N*(1-e_2)+H)*Math.Sin(B * p);
textBox3.Text = Convert.ToString(X);
textBox8.Text = Convert.ToString(Y);
textBox9.Text = Convert.ToString(Z);
//计算子午面直角坐标系
x =X/Math.Cos(L*p);
y = Z;
textBox2.Text = Convert.ToString(L);
textBox6.Text = Convert.ToString(x);
textBox7.Text = Convert.ToString(y);
}
else if (textBox7.Text != string.Empty&& textBox6.Text != string.Empty)//已知子午面直角坐标系
{
L = Convert.ToDouble(textBox2.Text);
x= Convert.ToDouble(textBox6.Text);
y= Convert.ToDouble(textBox7.Text);
//计算空间直角坐标系
X = x * Math.Cos(L * p);
Y = x * Math.Sin(L * p);
Z = y;
textBox3.Text = Convert.ToString(X);
textBox8.Text = Convert.ToString(Y);
textBox9.Text = Convert.ToString(Z);
//计算大地坐标系
double tan0 = Z / Math.Sqrt(X *X + Y *Y);
double P = c * e_2 / Math.Sqrt(X * X + Y * Y);
double tanB=tan0,cha;//循环迭代
do
{
cha = tanB;
tanB = tan0 + P * cha / Math.Sqrt(k + cha * cha);
} while (Math.Abs(cha-tanB) > Math.Pow(10, -10));
B = Math.Atan(tanB );
double W = Math.Sqrt(1 - e_2 * Math.Sin(B ) * Math.Sin(B ));
double V = Math.Sqrt(1 + e_dot_2 * Math.Cos(B ) * Math.Cos(B ));
double N = a / W;
H = Math.Sqrt(X * X + Y * Y) / Math.Cos(B ) - N;
textBox1.Text = Convert.ToString(L);
textBox4.Text = Convert.ToString(B * 180 / Math.PI);
textBox5.Text = Convert.ToString(H);
}
else if (textBox9.Text != string.Empty&& textBox8.Text != string.Empty)//已知空间直角坐标系
{
X = Convert.ToDouble(textBox3.Text);
Y = Convert.ToDouble(textBox8.Text);
Z = Convert.ToDouble(textBox9.Text);
//计算大地坐标系
L = Math.Atan(Y / X );
double tan0 = Z / Math.Sqrt(X * X + Y * Y);
double P = c * e_2 / Math.Sqrt(X * X + Y * Y);
double tanB = tan0, cha;//循环迭代
do
{
cha = tanB;
tanB = tan0 + P * cha / Math.Sqrt(k + cha * cha);
} while (Math.Abs(cha - tanB) > Math.Pow(10, -10));
B = Math.Atan(tanB );
double W = Math.Sqrt(1 - e_2 * Math.Sin(B ) * Math.Sin(B ));
double V = Math.Sqrt(1 + e_dot_2 * Math.Cos(B ) * Math.Cos(B));
double N = a / W;
H = Math.Sqrt(X * X + Y * Y) /Math.Cos(B ) - N;
textBox1.Text = Convert.ToString(L*180/Math.PI);
textBox4.Text = Convert.ToString(B *180/ Math.PI);
textBox5.Text = Convert.ToString(H);
//计算子午面直角坐标系
x = X / Math.Cos(L);
y = Z;
textBox2.Text = Convert.ToString(L*180/Math.PI);
textBox6.Text = Convert.ToString(x);
textBox7.Text = Convert.ToString(y);
}
}
}
}
到了这里,关于c#大地测量学各坐标系坐标转换(窗体应用程序)的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!