[英]how to get direction of one place to another from latitudes and longitudes of both place?
how to get direction of one place to another from latitudes and longitudes of both place? 如何从两个地方的经度和纬度获得一个地方到另一个地方的方向? as for example if source is Peru or Mexico and destination is Alaska then result should be around clockwise 45 degree north = anticlockwise 45 degree west.
例如,如果来源是秘鲁或墨西哥,目的地是阿拉斯加,则结果应为顺时针北45度=逆时针西45度。
i actually need a function that may return the result taking both lat lon of both source and destination.... 我实际上需要一个可以同时返回源和目标的纬度的结果的函数。
I am working in Android. 我正在使用Android。 But Here i just seek for the logic/calculation
但在这里我只是寻求逻辑/计算
Advance thanks 预先感谢
This formula will give you the initial heading to depart from the start point to the destination along a great circle: 该公式将为您提供沿大圆圈从起点到目的地的初始航向:
θ = atan2(sin(Δlong)*cos(lat2), cos(lat1)*sin(lat2) − sin(lat1)*cos(lat2)*cos(Δlong))
Where Δlong
is the overall change in longitude from start to destination and lat1
, lat2
are the latitude of the start/destination. 其中
Δlong
是从起点到终点的经度的总体变化,而lat1
, lat2
是起点/终点的纬度。
Note that the heading to the destination will change as you travel along the great circle, thus this heading would need to be continuously adjusted as you move toward the destination. 请注意,随着您沿着大圆圈行驶,前往目的地的航向将发生变化,因此,当您朝目的地移动时,将需要不断调整此航向。 Also note that you will need to map the angles returned by atan2() from +/- pi to 0-360°.
还要注意,您将需要将atan2()返回的角度从+/- pi映射到0-360°。
From: http://www.movable-type.co.uk/scripts/latlong.html 来自: http : //www.movable-type.co.uk/scripts/latlong.html
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.