指向 GPS 位置的方向
我得到了一个点的方位角、指南针方向和一个 api,它可以将箭头设置到某个方向(0 是顶部,90 是右侧,180 是底部,360 是顶部)
我如何计算箭头的正确值,如果我希望它指向我采用方位角形式的点?
谢谢
I got the azimuth of a point, the compass heading and an api which can set an arrow to a certain direction (0 is top, 90 is right, 180 is bottom, 360 is top)
how i calculate the correct value for the arrow if i want it to point to the point which i took the azimuth form?
thank you
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
两个纬度/经度坐标之间的航向公式为:
=atan2(cos(lat1)*sin(lat2)-sin(lat1)*cos(lat2)*cos(lon2-lon1),
sin(lon2-lon1)*cos(lat2))
其中 lat2/lon2 是终点,lat1/lon1 是起点。
您的答案将在 -pi 和 pi 弧度之间。
要获得以度为单位的航向,请将弧度转换为度,然后执行:(度+360)%360 = 航向。航向将为北 0,东航 90,等等。
指南针航向没有任何意义,除非您需要将航向从真北调整为磁北。
The formula for heading between two lat/long coords is:
=atan2(cos(lat1)*sin(lat2)-sin(lat1)*cos(lat2)*cos(lon2-lon1),
sin(lon2-lon1)*cos(lat2))
where lat2/lon2 is your end point, lat1/lon1 is your start point.
Your answer will be between -pi and pi radians.
To get the heading in degrees, convert your radians to degrees then do: (degrees+360)%360 = heading. The heading will then be 0 for north, 90 for east etc.
The compass heading means nothing, unless you need to adjust your heading from true north to magnetic north.
iPhone 指南针 GPS 方向
iPhone Compass GPS Direction