我有两个WGS84坐标,纬度和经度。这些点离得很近,例如相距只有一米。
有没有一种简单的方法来计算这些点之间的直线的方位角,也就是向北的角度?
天真的方法是假设一个笛卡尔坐标系(因为这些点离得很近),然后使用
sin(a) = abs(L2-L1) / sqrt(sqr(L2-L1) + sqr(B2-B1))
A=方位角,L2 =经度B1,B2 =纬度
随着坐标远离赤道,误差将变得更大,因为在赤道,两个经度之间的距离变得越来越小,而两个纬度之间的距离(保持不变)。
我发现了一些非常复杂的公式,我真的不想实现,因为它们对于离得太近的点似乎有点过分,而且我不需要非常高的精度(两个小数就足够了,一个小数可能也行,因为还有其他因素会降低精度,比如GPS返回的那个)。
也许我可以根据纬度确定一个近似的纵向校正因子,然后使用下面这样的东西:
sin(a) = abs(L2*f-L1*f) / sqrt(sqr(L2*f-L1*f) + sqr(B2-B1))
其中f是校正因子
有什么提示吗?
(我不想为此使用任何库,特别是那些需要运行时许可证的库。任何MPLed的Delphi源码都会很棒。)
发布于 2009-03-17 04:33:23
你在正文中引用的公式是计算两点之间的大圆距离。下面是我如何计算点之间的角度:
uses Math, ...;
...
const
cNO_ANGLE=-999;
...
function getAngleBetweenPoints(X1,Y1,X2,Y2:double):double;
var
dx,dy:double;
begin
dx := X2 - X1;
dy := Y2 - Y1;
if (dx > 0) then result := (Pi*0.5) - ArcTan(dy/dx) else
if (dx < 0) then result := (Pi*1.5) - ArcTan(dy/dx) else
if (dy > 0) then result := 0 else
if (dy < 0) then result := Pi else
result := cNO_ANGLE; // the 2 points are equal
result := RadToDeg(result);
end;
,
发布于 2009-06-26 19:48:27
以下是C#解决方案。已测试0、45、90、135、180、225、270和315个角度。
我用的解决方案的C#翻译替换了我之前丑陋的解决方案:
public double GetAzimuth(LatLng destination)
{
var longitudinalDifference = destination.Lng - this.Lng;
var latitudinalDifference = destination.Lat - this.Lat;
var azimuth = (Math.PI * .5d) - Math.Atan(latitudinalDifference / longitudinalDifference);
if (longitudinalDifference > 0) return azimuth;
else if (longitudinalDifference < 0) return azimuth + Math.PI;
else if (latitudinalDifference < 0) return Math.PI;
return 0d;
}
public double GetDegreesAzimuth(LatLng destination)
{
return RadiansToDegreesConversionFactor * GetAzimuth(destination);
}
发布于 2009-03-13 19:07:56
我找到了这个链接
http://williams.best.vwh.net/avform.htm
在答案中给出
Lat/Lon + Distance + Heading --> Lat/Lon
这看起来很有希望,特别是接近尾声时给出的平坦地球近似。
https://stackoverflow.com/questions/642555
复制相似问题