一名测绘工程专业的在校大学生,利用闲暇时间自学编程,写了一个测量小程序以供参考
程序运行界面:
该程序的理论基础为数字测图中的坐标方位角推算公式,利用Windows窗体应用程序技术具体实现,主要程序代码如下:
1 1 using System; 2 2 using System.Collections.Generic; 3 3 using System.ComponentModel; 4 4 using System.Data; 5 5 using System.Drawing; 6 6 using System.Linq; 7 7 using System.Text; 8 8 using System.Threading.Tasks; 9 9 using System.Windows.Forms; 10 11 namespace chuangti 11 12 { 12 13 public partial class Form1 : Form 13 14 { 14 15 public Form1() 15 16 { 16 17 InitializeComponent(); 17 18 } 18 19 private void button2_Click(object sender, EventArgs e) 19 20 { 20 21 Application.Exit(); 21 22 } 22 23 private void button1_Click(object sender, EventArgs e) 23 24 { 24 25 double yB,yA,xB,xA,d,f; 25 26 double.TryParse(textBox6.Text,out yB); 26 27 double.TryParse(textBox3.Text,out yA); 27 28 double.TryParse(textBox5.Text,out xB); 28 29 double.TryParse(textBox2.Text,out xA); 29 30 //double.TryParse(textBox8.Text,out z); 30 31 d = Math.Atan((yB - yA) / (xB - xA)); 31 32 f = Math.Sqrt((xB - xA)* (xB - xA)+ (yB - yA)* (yB - yA)); 32 33 //z = d; 33 34 string s = Convert.ToString(d); 34 35 string s1 = Convert.ToString(f); 35 36 textBox7.Text = s; 36 37 textBox8.Text = s1; 37 38 38 39 } 39 40 } 40 41 }