从一个坐标到另一个坐标的轴承
2022-09-02 11:08:50
我从 http://www.movable-type.co.uk/scripts/latlong.html 中实现了“轴承”公式。但它似乎非常不准确 - 我怀疑我的实现中存在一些错误。你能帮我找到它吗?我的代码如下:
protected static double bearing(double lat1, double lon1, double lat2, double lon2){
double longDiff= lon2-lon1;
double y = Math.sin(longDiff)*Math.cos(lat2);
double x = Math.cos(lat1)*Math.sin(lat2)-Math.sin(lat1)*Math.cos(lat2)*Math.cos(longDiff);
return Math.toDegrees((Math.atan2(y, x))+360)%360;
}