基础测绘计算函数设计(坐标正反算、交会计算)
生活随笔
收集整理的這篇文章主要介紹了
基础测绘计算函数设计(坐标正反算、交会计算)
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
基礎測繪計算函數設計
1.實驗內容
1.1 坐標正反算
1.2 交會計算
1.2.1 角度前方交會
1.2.2 角度后方交會
1.2.3 距離交會
2.界面展示
2.1主界面
2.2 坐標正反算
2.3 角度前方交會
2.4 角度后方交會
2.5 距離交會
3.附源代碼
3.1 定義表示平面坐標的類Point
class Point{public double x, y;//構造函數public Point(double x, double y){this.x = x; this.y = y;}public double Distance(Point p){return Math.Sqrt((x - p.x) * (x - p.x) + (y - p.y) * (y - p.y));}}3.2 主界面
private void button1_Click(object sender, EventArgs e){int iPos1 = comboBox1.SelectedIndex;//獲得當前選中行的索引switch(iPos1){case 0:{坐標正算 calculation1 = new 坐標正算();calculation1.ShowDialog();break;}case 1:{坐標反算 calculation2 = new 坐標反算();calculation2.ShowDialog();break;}}int iPos2 = comboBox2.SelectedIndex;switch(iPos2){case 0:{角度前方交會 calulation3 = new 角度前方交會();calulation3.ShowDialog();break;}case 1:{角度后方交會 calulation4 = new 角度后方交會();calulation4.ShowDialog();break;}case 2:{距離交會 calulation5 = new 距離交會();calulation5.ShowDialog();break;}}}3.3 坐標正算
private void button1_Click(object sender, EventArgs e){double x1 = double.Parse(textBox1.Text);double y1 = double.Parse(textBox2.Text);double rad = double.Parse(textBox5.Text);double distance = double.Parse(textBox6.Text);textBox3.Text = Convert.ToString(x1 + Math.Cos(rad)*distance);textBox4.Text = Convert.ToString(y1+Math.Sin(rad)*distance);}3.4 坐標反算
```csharp private void button1_Click(object sender, EventArgs e){double x1 = double.Parse(textBox3.Text);double y1 = double.Parse(textBox4.Text);double x2 = double.Parse(textBox5.Text);double y2 = double.Parse(textBox6.Text);Point p1 = new Point(x1, y1);Point p2 = new Point(x2, y2);textBox2.Text = Convert.ToString(p1.Distance(p2));//調用Point類中的Distance方法double x = x2 - x1;double y = y2 - y1;double Z =x/ y;double D;if(x>0){if(y>0){D = Math.Atan(Z);textBox1.Text = Convert.ToString(radtodms(D));}else{D = Math.Atan(Z) + 2 * Math.PI;textBox1.Text = Convert.ToString(radtodms(D));}}if(x==0){if(y>0){textBox1.Text = Convert.ToString(0);}else{D = Math.PI;textBox1.Text = Convert.ToString(radtodms(D));}}if(x<0){D = Math.Atan(Z) + Math.PI;textBox1.Text = Convert.ToString(D);}}3.5 角度前方交會
private void label8_Click(object sender, EventArgs e){double x1 = double.Parse(textBox1.Text);double y1 = double.Parse(textBox2.Text);double x2 = double.Parse(textBox4.Text);double y2 = double.Parse(textBox5.Text);double α1 = double.Parse(textBox3.Text);double α = radtodms(α1);double β1 = double.Parse(textBox6.Text);double β = radtodms(β1);double Z1 = x1 / Math.Tan(β) + x2 / Math.Tan(α) - y1 + y2;double D = 1 / Math.Tan(α) + 1 / Math.Tan(β);double Z2 = y1 / Math.Tan(β) + y2 / Math.Tan(α) + x1 - x2;double x3 = Z1 / D;double y3 = Z2 / D;textBox7.Text = Convert.ToString(x3);textBox8.Text = Convert.ToString(y3);}3.6 角度后方交會
private void button1_Click(object sender, EventArgs e){double x1 = double.Parse(x1_textBox1.Text);double y1 = double.Parse(y1_textBox2.Text);double x2 = double.Parse(x2_textBox3.Text);double y2 = double.Parse(y2_textBox4.Text);double x3 = double.Parse(x3_textBox5.Text);double y3 = double.Parse(y3_textBox6.Text);double α = double.Parse(textBox7.Text);double β = double.Parse(textBox8.Text);double γ = double.Parse(textBox9.Text);double A = Math.Atan((y3 - y1) / (x3 - x1)) - Math.Atan((y2 - y1) / (x2 - x1));double B = Math.Atan((y1 - y2) / (x1 - x2)) - Math.Atan((y3 - y2)/(x3-x2));double C = Math.Atan((y2 - y3) / (x2 - x3)) - Math.Atan((y1 - y3) / (x1 - x3));double P1 = 1 / ((1 / (Math.Tan(A))) - (1 / Math.Tan(α)));double P2 = 1 / ((1 / (Math.Tan(B))) - (1 / Math.Tan(β)));double P3 = 1 / ((1 / (Math.Tan(C))) - (1 / Math.Tan(γ)));double x4 = (P1 * x1 + P2 * x2 + P3 * x3) / (P1 + P2 + P3);double y4 = (P1 * y1 + P2 * x2 + P3 * y3) / (P1 + P2 + P3);x4_textBox10.Text = Convert.ToString(x4);y4_textBox11.Text = Convert.ToString(y4);}3.7 距離交會
private void button1_Click(object sender, EventArgs e){double x1 = double.Parse(textBox1.Text);double y1 = double.Parse(textBox2.Text);double x2 = double.Parse(textBox3.Text);double y2 = double.Parse(textBox4.Text);double Dap = double.Parse(Dap_textBox5.Text);double Dbp = double.Parse(Dbp_textBox6.Text);Point A = new Point(x1, y1);Point B = new Point(x2, y2);double Dab = A.Distance(B);double Za = Math.Acos((Dab * Dab + Dap * Dap - Dbp) / (2 * Dab * Dap));double Zb = Math.Acos((Dab * Dab + Dbp * Dbp - Dap) / (2 * Dab * Dbp));double Zab = Math.Atan((y2 - y1) / (x2 - x1));double Zap = Zab - Za;double Zbp = Zap + Zb;double xp1 = x1 + Dap * Math.Cos(Zap);double yp1 = y1 + Dap * Math.Sin(Zap);double xp2 = x2 + Dbp * Math.Cos(Zbp);double yp2 = y2 + Dbp * Math.Sin(Zbp);double xp = (xp1 + xp2) / 2;double yp = (yp1 + yp2) / 2;textBox7.Text = Convert.ToString(xp);textBox8.Text = Convert.ToString(yp);}如有不正確之處希望各位指出,非常感謝!!!
禁止抄襲!!!
總結
以上是生活随笔為你收集整理的基础测绘计算函数设计(坐标正反算、交会计算)的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: Always Day1 学会爱自己才
- 下一篇: 卡西欧4800坐标正反算通用程序(终极篇