2 个 GPS 坐标之间的角度 [英] Angle between 2 GPS Coordinates

查看:38
本文介绍了2 个 GPS 坐标之间的角度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用另一个使用 AR 的 iPhone 应用程序,我正在创建自己的框架,但是我在尝试获取相对于当前设备位置的第二个坐标的角度时遇到了麻烦,任何人都知道可以帮助我解决此问题的资源?

I'm working in another iPhone App that uses AR, and I'm creating my own framework, but I'm having trouble trying to get the angle of a second coordinate relative to the current device position, anyone know a good resource that could help me with this?

提前致谢!

推荐答案

如果两点足够接近,并且远离两极,你可以使用一些简单的三角函数:

If the two points are close enough together, and well away from the poles, you can use some simple trig:

float dy = lat2 - lat1;
float dx = cosf(M_PI/180*lat1)*(long2 - long1);
float angle = atan2f(dy, dx);

我忘了提到 latNlongN - 因此 dxdy - 可以是以度或弧度为单位,只要您不混合单位.然而,angle 总是以弧度返回.当然,乘以 180/M_PI 就可以恢复到度数.

I forgot to mention that latN and longN — and therefore dx and dy — can be in degrees or radians, so long as you don't mix units. angle, however, will always come back in radians. Of course, you can get it back to degrees if you multiply by 180/M_PI.

这篇关于2 个 GPS 坐标之间的角度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆