如何可视化的箭头指向某个坐标(纬度,经度),给定的PICH和偏航 [英] How to visualise an arrow pointing to a certain coordinates(latitude, longitude), given pich and yaw

查看:327
本文介绍了如何可视化的箭头指向某个坐标(纬度,经度),给定的PICH和偏航的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道如何想象一个箭头指向一个特定的坐标(纬度,经度) 而我走动牵着我的手机。

I would like to know how to visualise an arrow pointing to a certain coordinates(latitude, longitude) while I'm moving around holding my handset.

I'va计算出的所需的位置的俯仰和偏航。现在我想知道如何保持指向该位置同时移动。

I'va calculated the pitch and yaw of the desired position. Now I want to know how to keep pointing to this position while moving.

问候,

推荐答案

在一般的就可以计算出方位角(当地子午线和大圆连接您的当前位置,并从正北方向测量目标位置之间的夹角)使用这个公式:

In general you can calculate the bearing angle (the angle between your local meridian and the great circle connecting your current position and the target position measured from the north direction) using this formula:

double y = Math.sin(long2-long1)*Math.cos(lat2);
double x = Math.cos(lat1)*Math.sin(lat2) - Math.sin(lat1)*Math.cos(lat2)*Math.cos(long2-long1);
double bearing = Math.atan2(y, x);

注意 LAT1 long1 LAT2 long2 轴承都是弧度。该公式假设完美的球形地球。另请参见此页面

Note that lat1, long1, lat2, long2 and bearing are all in radians. The formula assumes perfectly spherical Earth. See also this page.

对于基于 WSG84 可以使用的 android.location.Location 的<一个href="http://developer.android.com/reference/android/location/Location.html#bearingTo%28android.location.Location%29"相对=nofollow> bearingTo() 的方法。

For more accurate results based on WSG84 you can use android.location.Location's bearingTo() method.

然后,你可以使用指南针和绘制箭头计算的方位角为南北线,也可以承担起北方说谎在您的手机屏幕的顶部。第二种方法使得有很大的意义,如果你显示的地图,因为大多数人都习惯于具有北极上方。

Then you can either use compass and draw the arrow at the computed bearing angle to the north-south line or you can assume the north to lie at the top of your phone's screen. The second approach makes a lot of sense if you display a map since most people are accustomed to having north at the top.

这篇关于如何可视化的箭头指向某个坐标(纬度,经度),给定的PICH和偏航的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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