//高斯反算
        private void btnSConvert_Click(object sender, EventArgs e)
        {
            //从ListView中获取坐标值
            List <string> listStrX = new List <string>();
            List <string> listStrY = new List <string>();

            Data.FromListView(this.listSSource, listStrX, listStrY);

            int ykm = Convert.ToInt32(txtYKM.Text) / 1000;
            //获取所选椭球参数值
            double a = Convert.ToDouble(txtA.Text);
            //由于double精度有限,所以选择通过扁率的倒数β来计算e的平方
            double e2 = (2 * Convert.ToDouble(txtB.Text) - 1) /
                        Convert.ToDouble(txtB.Text) / Convert.ToDouble(txtB.Text);
            Gauss gauss = new Gauss(a, e2);

            MyList <string> BLStr = new MyList <string>();

            for (int i = 0; i < listStrX.Count; i++)
            {
                double Brad = gauss.Get_Brad(Convert.ToDouble(listStrX[i]), Convert.ToDouble(listStrY[i]), ykm);
                double lRad = gauss.Get_lrad(Convert.ToDouble(listStrX[i]), Convert.ToDouble(listStrY[i]), ykm);
                double Bdms = Convert.ToDouble(DmsRad.rad2dms(Brad));
                double ldms = Convert.ToDouble(DmsRad.rad2dms(lRad));
                //保留四位小数
                BLStr.Add(String.Format("{0:f4}", Bdms), String.Format("{0:f4}", ldms));
            }

            listZDes.BeginUpdate();
            Data.AddDataList(listSDes, BLStr.ListX, BLStr.ListY);
            listZDes.EndUpdate();
        }
        private void btnSCal_Click(object sender, EventArgs e)
        {
            //获取所选椭球参数值
            double a = Convert.ToDouble(txtA.Text);
            //由于double精度有限,所以选择通过扁率的倒数β来计算e的平方
            double e2 = (2 * Convert.ToDouble(txtB.Text) - 1) /
                        Convert.ToDouble(txtB.Text) / Convert.ToDouble(txtB.Text);

            double n = 0;   //迭代次数或者迭代精度

            if (txtSE.Enabled)
            {
                n = Convert.ToDouble(txtSE.Text);
            }

            //存储从ListView中获取到弧长
            List <string> list = new List <string>();

            Data.FromListView(this.listLS, list);

            ArcLength     arc     = new ArcLength(a, e2);
            List <string> listRes = new List <string>();
            //经典迭代算法结果
            List <string> list_c = new List <string>();

            foreach (var item in list)
            {
                double rad = arc.B_standard(Convert.ToDouble(item), 1e-10);
                list_c.Add(Convert.ToDouble(DmsRad.rad2dms(rad)).ToString("0.0000"));
            }

            //根据数值积分计算弧长
            switch (this.cboxSMethod.SelectedIndex)
            {
            case 2:      //单点迭代法
                listRes.Clear();
                foreach (var item in list)
                {
                    double rad = arc.B_single(Convert.ToDouble(item), (int)n);
                    listRes.Add(Convert.ToDouble(DmsRad.rad2dms(rad)).ToString("0.0000"));
                }
                break;

            case 1:     //二分法
                listRes.Clear();
                foreach (var item in list)
                {
                    double rad = arc.B_half(Convert.ToDouble(item), n);
                    listRes.Add(Convert.ToDouble(DmsRad.rad2dms(rad)).ToString("0.0000"));
                }
                break;

            case 3:      //牛顿迭代法
                listRes.Clear();
                foreach (var item in list)
                {
                    double rad = arc.B_newton(Convert.ToDouble(item), (int)n);
                    listRes.Add(Convert.ToDouble(DmsRad.rad2dms(rad)).ToString("0.0000"));
                }
                break;

            case 4:     //割线法
                listRes.Clear();
                foreach (var item in list)
                {
                    double rad = arc.B_sec(Convert.ToDouble(item), (int)n);
                    listRes.Add(Convert.ToDouble(DmsRad.rad2dms(rad)).ToString("0.0000"));
                }
                break;

            case 6:     //欧拉迭代公式
                listRes.Clear();
                foreach (var item in list)
                {
                    double rad = arc.B_Euler_ex(Convert.ToDouble(item), (int)n);
                    listRes.Add(Convert.ToDouble(DmsRad.rad2dms(rad)).ToString("0.0000"));
                }
                break;

            case 7:     //欧拉预估-校正算法
                listRes.Clear();
                foreach (var item in list)
                {
                    double rad = arc.B_Euler_prex(Convert.ToDouble(item), (int)n);
                    listRes.Add(Convert.ToDouble(DmsRad.rad2dms(rad)).ToString("0.0000"));
                }
                break;

            case 8:     //2阶龙哥格库塔算法
                listRes.Clear();
                foreach (var item in list)
                {
                    double rad = arc.B_RK2x(Convert.ToDouble(item), (int)n);
                    listRes.Add(Convert.ToDouble(DmsRad.rad2dms(rad)).ToString("0.0000"));
                }
                break;

            case 9:     //4阶龙格-库塔算法
                listRes.Clear();
                foreach (var item in list)
                {
                    double rad = arc.B_RK4x(Convert.ToDouble(item), (int)n);
                    listRes.Add(Convert.ToDouble(DmsRad.rad2dms(rad)).ToString("0.0000"));
                }
                break;

            case 11:     //欧拉与牛顿迭代
                listRes.Clear();
                foreach (var item in list)
                {
                    double rad = arc.B_Euler_EX(Convert.ToDouble(item), (int)n);
                    listRes.Add(Convert.ToDouble(DmsRad.rad2dms(rad)).ToString("0.0000"));
                }
                break;

            case 12:     //欧拉预估-校正与牛顿迭代
                listRes.Clear();
                foreach (var item in list)
                {
                    double rad = arc.B_Euler_preX(Convert.ToDouble(item), (int)n);
                    listRes.Add(Convert.ToDouble(DmsRad.rad2dms(rad)).ToString("0.0000"));
                }
                break;

            case 13:     //2阶龙格-库塔算法与牛顿迭代
                listRes.Clear();
                foreach (var item in list)
                {
                    double rad = arc.B_RK2X(Convert.ToDouble(item), (int)n);
                    listRes.Add(Convert.ToDouble(DmsRad.rad2dms(rad)).ToString("0.0000"));
                }
                break;

            case 14:     //4阶龙格-库塔算法与牛顿迭代
                listRes.Clear();
                foreach (var item in list)
                {
                    double rad = arc.B_RK4X(Convert.ToDouble(item), (int)n);
                    listRes.Add(Convert.ToDouble(DmsRad.rad2dms(rad)).ToString("0.0000"));
                }
                break;

            default: break;
            }

            //在ListView中显示与结果
            if (cboxSMethod.SelectedIndex == 0)
            {
                Data.AddDataList(this.listLS, list, list_c);
            }
            else
            {
                List <string> listDif = XZ_dif(listRes, list_c);
                Data.AddDataList(this.listLS, list, listRes, listDif);
            }
        }
Exemple #3
0
        private void btnSCal_Click(object sender, EventArgs e)
        {
            //获取所选椭球参数值
            double a = Convert.ToDouble(txtA.Text);
            //由于double精度有限,所以选择通过扁率的倒数β来计算e的平方
            double e2 = (2 * Convert.ToDouble(txtB.Text) - 1) /
                        Convert.ToDouble(txtB.Text) / Convert.ToDouble(txtB.Text);

            int n = 0;   //迭代次数

            if (txtSE.Enabled)
            {
                n = Convert.ToInt32(txtSE.Text);
            }

            //存储从ListView中获取到弧长
            List <string> list = new List <string>();

            Data.FromListView(this.listLS, list);

            ArcLength     arc     = new ArcLength(a, e2);
            List <string> listRes = new List <string>();
            //经典迭代算法结果
            List <string> list_c = new List <string>();

            foreach (var item in list)
            {
                double rad = arc.B_standard(Convert.ToDouble(item), 1e-10);
                list_c.Add(Convert.ToDouble(DmsRad.rad2dms(rad)).ToString("0.0000"));
            }

            //根据数值积分计算弧长
            switch (this.cboxSMethod.SelectedIndex)
            {
            case 1:      //单点迭代法
                listRes.Clear();
                foreach (var item in list)
                {
                    double rad = arc.B_single(Convert.ToDouble(item), n);
                    listRes.Add(Convert.ToDouble(DmsRad.rad2dms(rad)).ToString("0.0000"));
                }
                break;

            case 2:      //牛顿迭代法
                listRes.Clear();
                foreach (var item in list)
                {
                    double rad = arc.B_newton(Convert.ToDouble(item), n);
                    listRes.Add(Convert.ToDouble(DmsRad.rad2dms(rad)).ToString("0.0000"));
                }
                break;

            case 3:     //割线法
                listRes.Clear();
                foreach (var item in list)
                {
                    double rad = arc.B_sec(Convert.ToDouble(item), n);
                    listRes.Add(Convert.ToDouble(DmsRad.rad2dms(rad)).ToString("0.0000"));
                }
                break;

            default: break;
            }

            //在ListView中显示与结果
            if (cboxSMethod.SelectedIndex == 0)
            {
                Data.AddDataList(this.listLS, list, list_c);
            }
            else
            {
                List <string> listDif = XZ_dif(listRes, list_c);
                Data.AddDataList(this.listLS, list, listRes, listDif);
            }
        }