界面如下,是大地测量问题的解算
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace 大地测量实习1
{
public partial class Form5 : Form
{
public Form5(object items)
{
InitializeComponent();
tuoqiu = Convert.ToString(items);
}
string tuoqiu;
double a, b, c, arf, ef, epf;
public void tq()
{
if (tuoqiu == "克拉索夫斯基椭球")
{
a = 6378245;
b = 6356863.0188;
c = 6399698.9018;
arf = 0.00335232986926;
ef = 0.00669342162297;
epf = 0.00673852541468;
}
else if (tuoqiu == "IUGG1975椭球")
{
a = 6378140;
b = 6356755.2882;
c = 6399596.6520;
arf = 0.00335281317790;
ef = 0.00669438499959;
epf = 0.00673950181947;
}
else if (tuoqiu == "CGCS2000椭球")
{
a = 6378137;
b = 6356752.3141;
c = 6399593.6259;
arf = 1 / 298.257222101;
ef = 0.00669438002290;
epf = 0.00673949677547;
}
}
private void Form5_Load(object sender, EventArgs e)
{
}
private void button1_Click(object sender, EventArgs e)
{
tq();
double B, L,X, N, t, m, nn,l3,l6,n3,n6,L0,x6,y6,Y6,x3,y3,Y3;
B = (Convert.ToDouble(textBox1.Text) * 3600 + Convert.ToDouble(textBox2.Text) * 60 + Convert.ToDouble(textBox3.Text)) / 3600;
L=(Convert.ToDouble(textBox4.Text) * 3600 + Convert.ToDouble(textBox5.Text) * 60 + Convert.ToDouble(textBox6.Text)) / 3600;
if (tuoqiu == "克拉索夫斯基椭球")
{
X = 111134.8611 * B - 16036.4803 * Math.Sin(2 * B / 360 * 2 * Math.PI) + 16.8281 * Math.Sin(4 * B / 360 * 2 * Math.PI) - 0.0220 * Math.Sin(6 * B / 360 * 2 * Math.PI);
}
else if (tuoqiu == "IUGG1975椭球")
{
X = 111133.0047 * B - 16038.5282 * Math.Sin(2 * B / 360 * 2 * Math.PI) + 16.8326 * Math.Sin(4 * B / 360 * 2 * Math.PI) - 0.0220 * Math.Sin(6 * B / 360 * 2 * Math.PI);
}
else if (tuoqiu == "CGCS2000椭球")
{
X = 111132.95254700 * B - 16038.508741268 * Math.Sin(2 * B / 360 * 2 * Math.PI) + 16.832613326622 * Math.Sin(4 * B / 360 * 2 * Math.PI) - 0.021984374201268 * Math.Sin(6 * B / 360 * 2 * Math.PI);
}
else X = 0;
n6=(int)(L/6)+1;
L0=n6*6-3;
l6=L-L0;
m = Math.Cos(B / 360 * 2 * Math.PI) * l6 * Math.PI / 180;
nn = Math.Sqrt(epf) * Math.Cos(B / 360 * 2 * Math.PI);
t = Math.Tan(B / 360 * 2 * Math.PI);
N = a / Math.Sqrt(1 - ef * Math.Sin(B / 360 * 2 * Math.PI) * Math.Sin(B / 360 * 2 * Math.PI));
x6 = X + N * t * (m * m / 2 + (5 - t * t + 9 * nn * nn + 4 * Math.Pow(nn, 4) * Math.Pow(m, 4)) / 24 + (61 - 58 * t * t + Math.Pow(t, 4)) * Math.Pow(m, 6) / 720);
y6 = N * (m + (1 - t * t + nn * nn) * Math.Pow(m, 3) / 6 + (5 - 18 * t * t + Math.Pow(t, 4) + 14 * nn * nn - 58 * nn * nn * t * t) * Math.Pow(m, 5) / 120);
Y6 = 19500000 + y6;
n3 = (int)((L -1.5)/ 3) + 1;
L0 = n3 * 3;
l3 = L - L0;
x3 = X + N * t * (m * m / 2 + (5 - t * t + 9 * nn * nn + 4 * Math.Pow(nn, 4) * Math.Pow(m, 4)) / 24 + (61 - 58 * t * t + Math.Pow(t, 4)) * Math.Pow(m, 6) / 720);
y3 = N * (m + (1 - t * t + nn * nn) * Math.Pow(m, 3) / 6 + (5 - 18 * t * t + Math.Pow(t, 4) + 14 * nn * nn - 58 * nn * nn * t * t) * Math.Pow(m, 5) / 120);
Y3 = 19500000 + y3;
textBox7.Text = Convert.ToString(x3);
textBox8.Text = Convert.ToString(y3);
textBox9.Text = Convert.ToString(Y3);
textBox10.Text = Convert.ToString(x6);
textBox11.Text = Convert.ToString(y6);
textBox12.Text = Convert.ToString(Y6);
}
private void button2_Click(object sender, EventArgs e)
{
tq();
double x, y, X, Y, B13, B23, B33, L13, L23, L33, L16, L26, L36,Vf,tf,Nf,nnf,A1,B1,C1,D1,Bf1,B,L3,L6,L30,L60,l,n;
double[] Bf = new double[1000];
X = Convert.ToDouble(textBox15.Text);
Y = Convert.ToDouble(textBox16.Text);
x = Convert.ToDouble(textBox13.Text);
y = Convert.ToDouble(textBox14.Text);
A1 = 1 + 3 / 4 * ef + 45 / 64 * ef * ef + 175 / 256 * ef * ef * ef;
B1 = 3 / 4 * ef + 15 / 16 * ef * ef + 525 / 512 * ef * ef * ef;
C1 = 15 / 64 * ef * ef + 105 / 256 * ef * ef * ef;
D1 = 35 / 512 * ef * ef * ef;
Bf[0] = X / (a * (1 - ef) * A1);
for (int i = 0; ; i++)
{
Bf[i + 1] = (X / (a * (1 - ef)) + B1 / 2 * Math.Sin(2 * Bf[i]) - C1 / 4 * Math.Sin(4 * Bf[i]) + D1 / 6 * Math.Sin(6 * Bf[i])) / A1;
if (Math.Abs(Bf[i + 1] - Bf[i]) <= 1 / Math.Pow(10, 20))
{ Bf1 = Bf[i]; break; }
}
tf = Math.Tan(Bf1);
Vf = Math.Sqrt(1 + epf * epf * Math.Cos(Bf1) * Math.Cos(Bf1));
Nf = c / Vf;
nnf = Math.Sqrt(epf) * Math.Cos(Bf1);
B = Bf1 / Math.PI * 180 - Vf * Vf * tf * (y * y / Nf / Nf - (5 + 3 * tf * tf + nnf * nnf - 9 * nnf * nnf * tf * tf) / 12 * Math.Pow((y / Nf), 4) + (61 + 90 * tf * tf + 45 * tf * tf) * Math.Pow((y / Nf), 6) / 360) / 2 * 180 / Math.PI;
l = (y / Nf - (1 + 2 * tf * tf + nnf * nnf) * Math.Pow((y / Nf), 3) / 6 + (5 + 28 * tf * tf + 24 * Math.Pow(tf, 4) + 6 * nnf * nnf + 8 * nnf * nnf * tf * tf) / 120 * Math.Pow((y / Nf), 5)) / Math.Cos(Bf1) * 180 / Math.PI;
n = (int)(Y / 1000000);
L30 = 3 * n;
L60 = n * 6 - 3;
L3 = L30 - l;
L6 = L60 - l;
L3 = L3 / Math.PI * 180;
L13 = (int)L3;
L23 = (int)((L3 - L13) * 60);
L33 = ((L3 - L13) * 60 - L23) * 60;
L16 = (int)L6;
L26 = (int)((L6 - L16) * 60);
L36 = ((L6 - L16) * 60 - L26) * 60;
B13 = (int)B;
B23 = (int)((B - B13) * 60);
B33 = ((B - B13) * 60 - B23) * 60;
textBox17.Text = Convert.ToString(B13);
textBox18.Text = Convert.ToString(B23);
textBox19.Text = Convert.ToString(B33);
textBox20.Text = Convert.ToString(L13);
textBox21.Text = Convert.ToString(L23);
textBox22.Text = Convert.ToString(L33);
textBox23.Text = Convert.ToString(B13);
textBox24.Text = Convert.ToString(B23);
textBox25.Text = Convert.ToString(B33);
textBox26.Text = Convert.ToString(L16);
textBox27.Text = Convert.ToString(L26);
textBox28.Text = Convert.ToString(L36);
}
}
}
不管输入什么数据,点击两个按钮就直接跳出
------解决思路----------------------
为什么不单步调试看看?然后你就知道问题出在哪里了
------解决思路----------------------
跳出是什么意思?Click事件中加try catch,加断点调试,看看问题在哪
------解决思路----------------------
只能一步步调式看看
------解决思路----------------------
先F5执行以下,点击按钮看哪里报错。
定位出来错误,别人才好帮你分析。
------解决思路----------------------
有异常了呗!!F5 单步调试一下