更新时间:2023-02-01 23:26:18
使用这个计算视角的角度:
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;
}