//计算方位角 返回角度
private double ComputeAzimuthAngle(double FromPntX, double FromPntY, double ToPntX, double ToPntY)
{
double jiao;
double ab = 0.0;
double dx;
double dy;
dx = ToPntX - FromPntX;//计算增量
dy = ToPntY - FromPntY;
jiao = Math.Abs(dx / dy);
if (dx > 0 && dy > 0)//四个象限的不同情况 第一象限
{
ab = Math.Atan(jiao);
}
if (dx == 0 && dy > 0)
{
ab = 0;
}
if (dx < 0 && dy > 0) //第四象限
{
ab = 2 * Math.PI - Math.Atan(jiao);
}
if (dx > 0 && dy == 0)
{
ab = Math.PI / 2;
}
if (dx == 0 && dy == 0)
{
ab = 0;
}
if (dx < 0 && dy == 0)
{
ab = Math.PI + Math.PI / 2;
}
if (dx < 0 && dy < 0) //第三象限
{
ab = Math.Atan(jiao) + Math.PI;
}
if (dx == 0 && dy < 0)
{
ab = Math.PI;
}
if (dx > 0 && dy < 0) //第二象限
{
ab = Math.PI - Math.Atan(jiao);
}
ab = ab / Math.PI * 180;//弧度转角度
return ab;
}