在 AR 中将 GPS 坐标转换为 opengl 单词
我有一个 GPS 坐标列表(长,纬度),我有我当前的位置(长,纬度)。 我发现,通过减去两个坐标,我找到了与我的位置相对的坐标,以及我在 AR 应用程序中用于在 opengl 世界中绘制 pois 的坐标。
问题是远处的坐标仍然太远而无法“看到”,所以我想要一个方程将所有内容转换为接近我的位置,但具有它们原始的相对位置。
double kGpsToOpenglCoorRatio = 1000;
- (void)convertGlobalCoordinatesToLocalCoordinates:(double)latitude x_p:(double *)x_p longitude:(double)longitude y_p:(double *)y_p {
*x_p = ((latitude - _userLocation.coordinate.latitude) * kGpsToOpenglCoorRatio);
*y_p = ((longitude - _userLocation.coordinate.longitude) * kGpsToOpenglCoorRatio);
}
我尝试应用平方根来给它们一个“距离限制”,但是它们的位置相对于原来的位置来说变得混乱了。
i have a list of gps coordinates (long,lat) and i have my current position (long,lat).
i found out that by subtracting the two coordinates i find the relative coordinates from my position, and that coordinates i use in my AR app to draw the pois in the opengl world.
the problem is that far-away coordinates will still be too far to "see", so i want an equation to translate everything to be close to my position, but with their original relative position.
double kGpsToOpenglCoorRatio = 1000;
- (void)convertGlobalCoordinatesToLocalCoordinates:(double)latitude x_p:(double *)x_p longitude:(double)longitude y_p:(double *)y_p {
*x_p = ((latitude - _userLocation.coordinate.latitude) * kGpsToOpenglCoorRatio);
*y_p = ((longitude - _userLocation.coordinate.longitude) * kGpsToOpenglCoorRatio);
}
i tried applying Square root in order to give them a "distance limit", but their positions got messed up relatively to their original position.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这可能是因为 GPS 使用球面坐标系,而您尝试将其直接映射到笛卡尔坐标系(平面)。
您可以做的是将 GPS 坐标转换为本地参考平面,而不是直接绘制它们。如果您将自己的位置视为坐标系的原点,则可以通过使用您所在位置与原点之间的大圆距离 (r) 和方位角 (theta) 来获取地平面上的点相对于原点和真北的极坐标。远程坐标,然后使用 (x,y) = (r*cos(theta), r*sin(theta)) 将其转换为笛卡尔坐标。
对于您的情况来说,更好的是,一旦您有了大圆轴承,您就可以缩短 r (距离)。这会将 x 和 y 上的点拖得更靠近您,但它们仍然处于正确的相对方位,您只需要以某种方式指示这一点即可。
另一种方法是缩放您正在可视化的对象的大小,以便它们随着距离的增加而变大,以补偿透视。这样你就可以直接使用正确的位置和方向。
此页面具有方位/距离算法:http://www.movable-type。 co.uk/scripts/latlong.html
This might be because GPS uses a spherical(ish) coordinate system, and you're trying to directly map it to a cartesian coordinate system (a plane).
What you could to do is convert your GPS coordinates to a local reference plane, rather than map them directly. If you consider your own location the origin of your coordinate system, you can get the polar coordinates of the points on the ground plane relative to the origin and true north by using great circle distance (r) and bearing (theta) between your location and the remote coordinate, and then covert that to cartesian coordinates using (x,y) = (r*cos(theta), r*sin(theta)).
Better again for your case, once you have the great circle bearing, you can just foreshorten r (the distance). That will drag the points closer to you in both x and y, but they'll still be at the correct relative bearing, you'll just need to indicate this somehow.
Another approach is to scale the size of the objects you're visualizing so that they get larger with distance to compensate for perspective. This way you can just directly use the correct position and orientation.
This page has the bearing/distance algorithms: http://www.movable-type.co.uk/scripts/latlong.html
我最终使用与我希望所有点都出现在其上的圆截取的 GPS 坐标方程来解决它,它工作得很好。我没有在任何地方使用轴承。
如果有人感兴趣,这里是代码:
I ended up solving it using the equation of the gps coordinate intercepted with the circle i want all the pois to appear on, it works perfectly. I didn't use bearings anywhere.
here is the code if anyone interested: