【发布时间】:2016-09-12 08:46:41
【问题描述】:
我需要计算三个地理位置之间的角度,其中两个始终相同,只有一个在变化(例如当用户走路时)。
第一个点是用户的起始位置。第二个点是用户的当前位置,所以一开始第一个点等于第二个点。第一个点和固定点总是相同的。我有每个点的纬度和经度。
我尝试使用这个公式:
double angle1 = Math.atan2(startingLocation.getLongitude() - destinationLocation.getLongitude(), startingLocation.getLatitude() - destinationLocation.getLatitude());
double angle2 = Math.atan2(currentLocation.getLongitude() - destinationLocation.getLongitude(), currentLocation.getLatitude() - destinationLocation.getLatitude());
return Math.toDegrees(angle1 - angle2);
但是例如,当第一个点 == 第二个点 i 时,除了度数为 0。但它给了我奇怪的结果,比如 176 度。问题出在哪里?
【问题讨论】:
-
@Sabish.M 我只借了这个话题的图。
标签: java android geolocation angle