Exemple #1
0
        //弧度转度分秒
        public static AngleDMS ARC2DMS(double ARC)
        {
            double   Temp   = ARC2DEC(ARC);
            AngleDMS Result = DEC2DMS(Temp);

            return(Result);
        }
Exemple #2
0
        //度分秒转弧度
        public static double DMS2ARC(AngleDMS DMS)
        {
            AngleDEC TempDEC = new AngleDEC();
            AngleARC Result  = new AngleARC();

            TempDEC.DEC = DMS2DEC(DMS);
            Result.ARC  = DEC2ARC(TempDEC);
            return(Result.ARC);
        }
Exemple #3
0
 //角度转文本
 internal static string DMS2Str(AngleDMS DMS)
 {
     if (DMS.Degree < 0 || DMS.Minute < 0 || DMS.Second < 0)
     {
         return("-" + Convert.ToString(Math.Abs(DMS.Degree) + "° " + Math.Abs(DMS.Minute) + "′ " + Math.Abs(DMS.Second).ToString("0.0000") + "″"));
     }
     else
     {
         return(Convert.ToString(DMS.Degree + "° " + DMS.Minute + "′ " + DMS.Second.ToString("0.0000") + "″"));
     }
 }
Exemple #4
0
        //十进制转度分秒
        public static AngleDMS DEC2DMS(double X)
        {
            AngleDMS Result = new AngleDMS
            {
                Degree = (int)X
            };

            Result.Minute = (int)((X - Result.Degree) * 60);
            Result.Second = (((X - Result.Degree) * 60 - Result.Minute) * 60);
            while (Result.Second >= 60)
            {
                Result.Second -= 60;
                Result.Minute += 1;
                while (Result.Minute >= 60)
                {
                    Result.Minute -= 60;
                    Result.Degree += 1;
                }
            }
            return(Result);
        }
Exemple #5
0
        //度分秒转十进制
        public static double DMS2DEC(AngleDMS DMS)
        {
            double Result = DMS.Degree + DMS.Minute / 60.0 + DMS.Second / 3600.0;

            return(Result);
        }
Exemple #6
0
        //计算
        private void Calculate(object sender, EventArgs e)
        {
            try
            {
                if (InputDataGridView.RowCount < 5)
                {
                    throw new Exception("小于四个点算个毛线啊!");
                }

                ReTime = 0; //迭代次数归零

                //读取文本框
                m  = Convert.ToDouble(RatioTextBox.Text);                   //像片比例尺
                f  = Convert.ToDouble(InnerFTextBox.Text);                  //主距
                x0 = Convert.ToDouble(InnerXTextBox.Text);                  //内方位元素
                y0 = Convert.ToDouble(InnerYTextBox.Text);
                int ReTimeLimit = Convert.ToInt32(ReTimeLimitTextBox.Text); //迭代次数上限

                //限差转成十进制度
                AngleDMS Limit = new AngleDMS
                {
                    Degree = 0,
                    Minute = 0,
                    Second = Convert.ToDouble(LimitTextBox.Text)
                };

                //清空点位记录
                PhotoPoint.Clear();
                GroundPoint.Clear();
                ResultTextBox.Text = "这里什么都没有,好冷清啊。快点击“计算”吧!";

                //逐行写入点位记录
                for (int i = 0; i < InputDataGridView.RowCount - 1; i++)
                {
                    PhotoPoint.Add(new ResectionPoint
                    {
                        X = (Convert.ToDouble(InputDataGridView[1, i].Value) - x0) / 1000,
                        Y = (Convert.ToDouble(InputDataGridView[2, i].Value) - y0) / 1000,
                        Z = -f / 1000
                    });

                    GroundPoint.Add(new ResectionPoint
                    {
                        X = Convert.ToDouble(InputDataGridView[3, i].Value),
                        Y = Convert.ToDouble(InputDataGridView[4, i].Value),
                        Z = Convert.ToDouble(InputDataGridView[5, i].Value)
                    });
                }

                double[,] Result = { { 0 }, { 0 }, { 0 }, { 0 }, { 0 }, { 0 } };                                                                     //初始化结果矩阵
                double[,] RM     = new double[3, 3];                                                                                                 //初始化旋转矩阵
                double[,] Q      = new double[6, 6];                                                                                                 //初始化中误差矩阵

                ResectionCalc.CalcMain(PhotoPoint, GroundPoint, m, f / 1000, IO.DMS2DEC(Limit), ReTimeLimit, ref Result, ref ReTime, out RM, out Q); //求外方位元素

                //转换并输出
                string ResultXs    = Result[0, 0].ToString("0.0000");
                string ResultYs    = Result[1, 0].ToString("0.0000");
                string ResultZs    = Result[2, 0].ToString("0.0000");
                string Resultphi   = IO.DMS2Str(IO.DEC2DMS(Result[3, 0]));
                string ResultOmega = IO.DMS2Str(IO.DEC2DMS(Result[4, 0]));
                string Resultkappa = IO.DMS2Str(IO.DEC2DMS(Result[5, 0]));
                string Diffphi     = IO.DMS2Str(IO.DEC2DMS(Q[3, 3]));
                string DiffOmega   = IO.DMS2Str(IO.DEC2DMS(Q[4, 4]));
                string Diffkappa   = IO.DMS2Str(IO.DEC2DMS(Q[5, 5]));
                string ResultRM    = "";

                //旋转矩阵转文本
                for (int i = 0; i < RM.GetLength(0); i++)
                {
                    for (int j = 0; j < RM.GetLength(1); j++)
                    {
                        ResultRM += RM[i, j].ToString("0.0000") + ", ";
                    }
                    ResultRM += "\r\n";
                }

                //设置文本框文本
                ResultTextBox.Text = "Xs = " + ResultXs + " (m)\r\nYs = " + ResultYs + " (m)\r\nZs = " + ResultZs + " (m)\r\nφ = " + Resultphi + "\r\nω = " + ResultOmega + "\r\nк = " + Resultkappa + "\r\n旋转矩阵为:\r\n" + ResultRM + "共迭代 " + Convert.ToString(ReTime) + " 次" + "\r\nXs精度为:" + Q[0, 0].ToString("0.0000") + " (m)\r\nYs精度为:" + Q[1, 1].ToString("0.0000") + " (m)\r\nZs精度为:" + Q[2, 2].ToString("0.0000") + " (m)\r\nφ精度为:" + Diffphi + "\r\nω精度为:" + DiffOmega + "\r\nк精度为:" + Diffkappa;

                //控件设置
                SaveToFileButton.Enabled = true;
                ResultGifBox.Visible     = false;
            }
            catch (Exception err)
            {
                MessageBox.Show(err.Message, "Err", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }