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); } }
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); } }