public int XYZ2BLH(PointXYZ xyz, double a, double f, ref PointBLH blh) { double error = 0; Ellispoid E = new Ellispoid(); E.a = a; E.f = f; blh.Name = xyz.Name; double x = xyz.X + error; double y = xyz.Y + error; double z = xyz.Z + error; double B0 = Math.Atan(z / Math.Sqrt(Math.Pow(x, 2) + Math.Pow(y, 2))); blh.L = Math.Atan(y / x); while (true) { CalculateEllispoid(ref E, B0); blh.B = Math.Atan((z + E.N * Math.Pow(E.e1, 2) * Math.Sin(B0)) / Math.Sqrt(Math.Pow(x, 2) + Math.Pow(y, 2))); if (Math.Abs(blh.B - B0) <= Math.Pow(10.0, -15.0)) { break; } else { B0 = blh.B; } } blh.H = Math.Sqrt(Math.Pow(x, 2) + Math.Pow(y, 2)) / Math.Cos(blh.B) - E.N; return(0); }
private void 空间直角坐标XYZ转大地坐标BLHToolStripMenuItem_Click(object sender, EventArgs e) { if (sign == 1) { if (sign1 == 1) { LpBLH.Clear(); Conversion convert = new Conversion(); int count = LpXYZ.Count; for (int i = 0; i < count; i++) { PointBLH blh = new PointBLH(); convert.XYZ2BLH(LpXYZ[i], E.a, E.f, ref blh); LpBLH.Add(blh); } int style = 1; writeListView(style); style = 12; writeFile(style); } else { MessageBox.Show("错误:请先进行 “大地坐标(B,L,H)转空间直角坐标(X,Y,Z)” 操作!"); } } }
public int BLH2XYZ(PointBLH blh, Ellispoid E, ref PointXYZ xyz) { xyz.Name = blh.Name; xyz.X = (E.N + blh.H) * Math.Cos(blh.B) * Math.Cos(blh.L); xyz.Y = (E.N + blh.H) * Math.Cos(blh.B) * Math.Sin(blh.L); xyz.Z = (E.N * (1 - Math.Pow(E.e1, 2)) + blh.H) * Math.Sin(blh.B); return(0); }
private int boxToList() { string s1 = richTextBox1.Text; s1 = s1.Trim(); s1 = s1.Replace(" ", ""); s1 = s1.Replace("\t", ""); string[] s2 = s1.Split(new char[] { '\r', '\n' }, StringSplitOptions.RemoveEmptyEntries); List <string[]> s3 = new List <string[]>(); foreach (string tmp in s2) { s3.Add(tmp.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries)); } string[][] s4 = s3.ToArray(); E.a = double.Parse(s4[0][1]); E.f = 1 / double.Parse(s4[1][1]); double L0 = double.Parse(s4[2][1]); int row = s4.GetLength(0); for (int i = 3; i < row; i++) { Conversion convert = new Conversion(); PointBLH p = new PointBLH(); PointBLL0 p0 = new PointBLL0(); p.Name = s4[i][0]; p.B = convert.Angle2Radian(double.Parse(s4[i][1])); p.L = convert.Angle2Radian(double.Parse(s4[i][2])); p.H = double.Parse(s4[i][3]); p0.Name = s4[i][0]; p0.B = convert.Angle2Radian(double.Parse(s4[i][1])); p0.L = convert.Angle2Radian(double.Parse(s4[i][2])); p0.L0 = convert.Angle2Radian(L0); LpBLH.Add(p); LpBLL0.Add(p0); } return(0); }