常用测量程序设计
(1)用全站仪在 A 点观测了 B 点斜边和垂直角,求 A 到 B 的高差。
a i
,D--斜边,a--垂直角,i --仪器高,v --反
v
(提示:
h
AB
D
sin
a
(1
k
)
2
D
2
R
2
cos
光镜高, k --大气折光系数)
using System;
using System.Collections.Generic;
using System.Text;
namespace ConsoleApplication1
{
class Application
{
static void Main(string[] args)
{
Console.Write("请输入斜边=");
double D = double.Parse(Console.ReadLine());
Console.Write("请输入垂直角[ddd.mmss]=");
double a = DEG(double.Parse(Console.ReadLine()));
Console.Write("请输入仪器高=");
double i = double.Parse(Console.ReadLine());
Console.Write("请输入反光镜高=");
double v = double.Parse(Console.ReadLine());
double h = D * Math.Sin(a) + (1 - 0.13) * D / 6371000.0 * D / 6371000.0 * Math.Cos(a)
* Math.Cos(a) / 2.0 + i - v;
Console.WriteLine("高差为{0}",h);
}
//将ddd.mmss转为弧度
static public double DEG(double ang)
int fuhao = (int)(ang / Math.Abs(ang));
ang = Math.Abs(ang);
int d = (int)ang;
int m = ((int)(ang * 100)) - d * 100;
double s = ang * 10000 - m * 100 - d * 10000;
return ((d + m / 60.0 + s / 3600.0) * fuhao) / 180.0 * Math.PI;
{
}
}
}
(2)如图所示,已知 A 点的坐标及 A 点到 B 点的边长及方位角,计算 B 点的坐标。
using System;
using System.Collections.Generic;
using System.Text;
namespace ConsoleApplication1
{
class Application
{
static void Main(string[] args)
{
}
Console.Write("请输入A点的X坐标=");
double XA = double.Parse(Console.ReadLine());
Console.Write("请输入A点的Y坐标=");
double YA = double.Parse(Console.ReadLine());
Console.Write("请输入A到B的方位角[ddd.mmss]=");
double a = DEG(double.Parse(Console.ReadLine()));
Console.Write("请输入A到B的水平距离=");
double S = double.Parse(Console.ReadLine());
double XB = XA + S*Math.Cos(a);
double YB = YA + S*Math.Sin(a);
Console.WriteLine("B点的坐标({0},{1})",XB,YB);
//将ddd.mmss转为弧度
static public double DEG(double ang)
int fuhao = (int)(ang / Math.Abs(ang));
ang = Math.Abs(ang);
int d = (int)ang;
int m = ((int)(ang * 100)) - d * 100;
double s = ang * 10000 - m * 100 - d * 10000;
return ((d + m / 60.0 + s / 3600.0) * fuhao) / 180.0 * Math.PI;
{
}
}
}
(3)如图所示,已知 A 点和 B 点的坐标,计算 A 点到的边长及方位角。
using System;
using System.Collections.Generic;
using System.Text;
namespace ConsoleApplication1
{
class Application
{
static void Main(string[] args)
{
}
Console.Write("请输入A点的X坐标=");
double XA = double.Parse(Console.ReadLine());
Console.Write("请输入A点的Y坐标=");
double YA = double.Parse(Console.ReadLine());
Console.Write("请输入B点的X坐标=");
double XB = double.Parse(Console.ReadLine());
Console.Write("请输入B点的Y坐标=");
double YB = double.Parse(Console.ReadLine());
double S = 距离(XA, YA, XB, YB);
double a = 方位角(XA, YA, XB, YB);
Console.WriteLine("AB间的距离={0},从A到B的方位角={1}",S,DMS(a));
//将弧度转为ddd.mmss
static public double DMS(double ang)
{
}
ang += 1.0E-15;//加上一个小量,以保证进位
int fuhao = (int)(ang / Math.Abs(ang));
ang = Math.Abs(ang) * 180.0 / Math.PI;
int d = (int)ang;
ang = (ang - d) * 60.0;
int m = (int)ang;
double s = (ang - m) * 60.0;
return (d + m / 100.0 + s / 10000.0) * fuhao;
//计算方位角,返回弧度值
public static double 方位角(double x1, double y1, double x2, double y2)
{
double deltaX = x2 - x1;
double deltaY = y2 - y1;
double angle = Math.PI * 0.5;
if (Math.Abs(deltaX) > 0.000000001)
{
}
angle = Math.Atan2(deltaY, deltaX);
if (angle < 0)
{
}
angle += Math.PI;
if (deltaY < 0.0)
{
}
angle += Math.PI;
return angle;
}
//计算距离
public static double 距离(double x1, double y1, double x2, double y2)
return Math.Sqrt((x2 - x1) * (x2 - x1) + (y2 - y1) * (y2 - y1));
{
}
}
}
(4)在如图所示的支中导线,已知 A 点到 M 点的坐标方位角 0a 及每个左角,求每条边的
坐标方位角。
using System;
using System.Collections.Generic;
using System.Text;
namespace ConsoleApplication1
{
class Application
{
static void Main(string[] args)
{
Console.Write("请输入A点到M点的坐标方位角=");
//将A点到M点的坐标方位角换算为M点到A点的坐标方位角,以便利用公式
double a0 = DEG(double.Parse(Console.ReadLine()) +180.0);
if (a0 > 2 * Math.PI)
{
}
a0 -= 2 * Math.PI;
List 导线转角集合 = new List();
int i = 1;
do
{
Console.Write("请输入第{0}个转角的水平角[左角为正,右角为负] <直接回车结束输
入>=",i++);
string str = Console.ReadLine();
if (str != "")
{
}
导线转角集合.Add(DEG(double.Parse(str)));
else
{
}
break;
} while (true);
i = 1;
foreach (double a in 导线转角集合)
{
a0 += a + Math.PI;
if (a0 > 2 * Math.PI)
{
}
a0 -= 2 * Math.PI;
else if (a0 < 0.0)
{
}
a0 += 2 * Math.PI;
Console.WriteLine("第{0}条边的方位角为{1}",i++,DMS(a0));
}
}
//将弧度转为ddd.mmss
static public double DMS(double ang)
{
}
ang += 1.0E-15;//加上一个小量,以保证进位
int fuhao = (int)(ang / Math.Abs(ang));
ang = Math.Abs(ang) * 180.0 / Math.PI;
int d = (int)ang;
ang = (ang - d) * 60.0;
int m = (int)ang;
double s = (ang - m) * 60.0;
return (d + m / 100.0 + s / 10000.0) * fuhao;
//将ddd.mmss转为弧度
static public double DEG(double ang)
{
int fuhao = (int)(ang / Math.Abs(ang));
ang = Math.Abs(ang);
int d = (int)ang;
int m = ((int)(ang * 100)) - d * 100;
double s = ang * 10000 - m * 100 - d * 10000;
return ((d + m / 60.0 + s / 3600.0) * fuhao) / 180.0 * Math.PI;
}
}
}
(5)在如图所示的支中导线,已知 A 点和 M 点的坐标及每个左角和每条边长,求每个点的
坐标。
using System;
using System.Collections.Generic;
using System.Text;
namespace ConsoleApplication1
{
class Application
{
static void Main(string[] args)
{
Console.Write("请输入M点的x坐标=");
double Mx = double.Parse(Console.ReadLine());
Console.Write("请输入M点的y坐标=");
double My = double.Parse(Console.ReadLine());
Console.Write("请输入A点的x坐标=");
double Ax = double.Parse(Console.ReadLine());
Console.Write("请输入A点的y坐标=");
double Ay = double.Parse(Console.ReadLine());
List 导线转角集合 = new List();
List 导线边长集合 = new List();
int i = 1;
do
{
Console.Write("请输入第{0}个转角的水平角[左角为正,右角为负]<直接回车结束输
入>=",i);
string str = Console.ReadLine();
if (str != "")
{
导线转角集合.Add(DEG(double.Parse(str)));
}
else
{
}
break;
Console.Write("请输入第{0}条边长值=", i++);
导线边长集合.Add( double.Parse(Console.ReadLine()));
} while (true);
//计算M到A的坐标方位角
double a0 = 方位角(Mx, My, Ax, Ay);
//计算每个点的坐标
double x0 = Ax;
double y0 = Ay;
for (int j = 0; j < 导线转角集合.Count; j++)
{
}
a0 += 导线转角集合[j] + Math.PI;
if (a0 > 2 * Math.PI) a0 -= 2 * Math.PI;
x0 = x0 + 导线边长集合[j] * Math.Cos(a0);
y0 = y0 + 导线边长集合[j] * Math.Sin(a0);
Console.WriteLine("P{0}点的坐标是:{1},{2}",j+2,x0,y0);
}
//将ddd.mmss转为弧度
static public double DEG(double ang)
{
}
int fuhao = (int)(ang / Math.Abs(ang));
ang = Math.Abs(ang);
int d = (int)ang;
int m = ((int)(ang * 100)) - d * 100;
double s = ang * 10000 - m * 100 - d * 10000;
return ((d + m / 60.0 + s / 3600.0) * fuhao) / 180.0 * Math.PI;
//计算方位角,返回弧度值
public static double 方位角(double x1, double y1, double x2, double y2)
{
double deltaX = x2 - x1;
double deltaY = y2 - y1;
double angle = Math.PI * 0.5;
if (Math.Abs(deltaX) > 0.000000001)
{
}
angle = Math.Atan2(deltaY, deltaX);
if (angle < 0)
{
angle += Math.PI;
}
if (deltaY < 0.0)
{
}
angle += Math.PI;
return angle;
}
}
}
(6)在如图所示的单一附合水准路线中,已知 A 点和 B 点的高程及每段的长度和高差,求
每个点的高程。
using System;
using System.Collections.Generic;
using System.Text;
namespace ConsoleApplication1
{
class Application
{
static void Main(string[] args)
{
Console.Write("请输入A点的高程=");
double Ha = double.Parse(Console.ReadLine());
Console.Write("请输入B点的高程=");
double Hb = double.Parse(Console.ReadLine());
List 路线段长度集合 = new List();
List 路线段高差集合 = new List();
int i = 1;
do
{
Console.Write("请输入第{0}段长度[公里为单位]<直接回车结束输入>=",i);
string str = Console.ReadLine();
if (str != "")
{
}
路线段长度集合.Add(double.Parse(str));
else
{
break;