我有两个坐标在Lat Long格式.
如何从A点(例如纽约37.149472,-95.509544)确定以B为单位的方向(例如Toronto 40.714269,-74.005973)
我正在寻找一个值,如“340度”
在C#
解决方法
如果你想要一贯的轴承跟随你不想要最短的(大圆)路径,你想要一条Rhumb线
转换可移动类型脚本
static double DegreeBearing( double lat1,double lon1,double lat2,double lon2) { var dLon = ToRad(lon2-lon1); var dPhi = Math.Log( Math.Tan(ToRad(lat2)/2+Math.PI/4)/Math.Tan(ToRad(lat1)/2+Math.PI/4)); if (Math.Abs(dLon) > Math.PI) dLon = dLon > 0 ? -(2*Math.PI-dLon) : (2*Math.PI+dLon); return ToBearing(Math.atan2(dLon,dPhi)); } public static double ToRad(double degrees) { return degrees * (Math.PI / 180); } public static double ToDegrees(double radians) { return radians * 180 / Math.PI; } public static double ToBearing(double radians) { // convert radians to degrees (as bearing: 0...360) return (ToDegrees(radians) +360) % 360; } // verify against the website example DegreeBearing(50.36389,-4.15694,42.35111,-71.04083);