计算两个纬度/经度点之间的角度 [英] Calculate angle between two Latitude/Longitude points
本文介绍了计算两个纬度/经度点之间的角度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
但我只有两点(Lng / Ltd)
Thx
解决方案
使用这个计算视角的角度:
private double angleFromCoordinate(double lat1,double long1,double lat2,
double long2){
double dLon =(long2 - long1);
double y = Math.sin(dLon)* Math.cos(lat2);
double x = Math.cos(lat1)* Math.sin(lat2) - Math.sin(lat1)
* Math.cos(lat2)* Math.cos(dLon);
double brng = Math.atan2(y,x);
brng = Math.toDegrees(brng);
brng =(brng + 360)%360;
brng = 360 - brng; //计算逆时针度数 - 删除顺时针
返回brng;
}
Is there a way to calculate angle between two Latitude/Longitude points?
What I am trying to achieve is to know where the user is heading. For example, user is heading North, South,.... South-East, etc.
But I have only two points (Lng/Ltd)
Thx
解决方案
using this referance to calculate Angle:
private double angleFromCoordinate(double lat1, double long1, double lat2,
double long2) {
double dLon = (long2 - long1);
double y = Math.sin(dLon) * Math.cos(lat2);
double x = Math.cos(lat1) * Math.sin(lat2) - Math.sin(lat1)
* Math.cos(lat2) * Math.cos(dLon);
double brng = Math.atan2(y, x);
brng = Math.toDegrees(brng);
brng = (brng + 360) % 360;
brng = 360 - brng; // count degrees counter-clockwise - remove to make clockwise
return brng;
}
这篇关于计算两个纬度/经度点之间的角度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文