GPS中误差计算 public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
double x1, x2, x3, x4, x5, x6, y1, y2, y3, y4, y5, y6, h1, h2, h3, h4, h5, h6;
double sumx = 0;
double sumy = 0;
double sumh = 0;
double avgx = 0;
double avgy = 0;
double avgh = 0;
double zwcx, zwcy, zwch;
x1 = Convert.ToDouble(textBox1.Text);
x2 = Convert.ToDouble(textBox3.Text);
x3 = Convert.ToDouble(textBox5.Text);
x4 = Convert.ToDouble(textBox7.Text);
x5 = Convert.ToDouble(textBox9.Text);
x6 = Convert.ToDouble(textBox11.Text);
y1 = Convert.ToDouble(textBox2.Text);
y2 = Convert.ToDouble(textBox4.Text);
y3 = Convert.ToDouble(textBox6.Text);
y4 = Convert.ToDouble(textBox8.Text);
y5 = Convert.ToDouble(textBox10.Text);
y6 = Convert.ToDouble(textBox12.Text);
h1 = Convert.ToDouble(textBox13.Text);
h2 = Convert.ToDouble(textBox14.Text);
h3 = Convert.ToDouble(textBox15.Text);
h4 = Convert.ToDouble(textBox16.Text);
h5 = Convert.ToDouble(textBox17.Text);
h6 = Convert.ToDouble(textBox18.Text);
sumx = x1 x2 x3 x4 x5 x6;
sumy = y1 y2 y3 y4 y5 y6;
sumh = h1 h2 h3 h4 h5 h6;
avgx = sumx / 6;
avgy = sumy / 6;
avgh = sumh / 6;
zwcx = Math.Sqrt(Math.Pow(x1 - avgx, 2) Math.Pow(x2 - avgx, 2) Math.Pow(x3 - avgx, 2) Math.Pow(x4 - avgx, 2) Math.Pow(x5 - avgx, 2) Math.Pow(x6 - avgx, 2)) / 5;
zwcy = Math.Sqrt(Math.Pow(y1 - avgy, 2) Math.Pow(y2 - avgy, 2) Math.Pow(y3 - avgy, 2) Math.Pow(y4 - avgy, 2) Math.Pow(y5 - avgy, 2) Math.Pow(y6 - avgy, 2)) / 5;
zwch = Math.Sqrt(Math.Pow(h1 - avgh, 2) Math.Pow(h2 - avgh, 2) Math.Pow(h3 - avgh, 2) Math.Pow(h4 - avgh, 2) Math.Pow(h5 - avgh, 2) Math.Pow(h6 - avgh, 2)) / 5;
textBox19.Text = Convert.ToString(zwcx);
textBox20.Text = Convert.ToString(zwcy);
textBox21.Text = Convert.ToString(zwch);
}
}
评论