Created
February 28, 2015 06:55
-
-
Save aaryadev/3f060bb8e8bf1007e59f to your computer and use it in GitHub Desktop.
bearing between 2 gps location
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static double gpsbearing(double lat1, double long1, double lat2, double long2){ | |
double dLon= Math.toRadians(long2-long1); | |
double latA=Math.toRadians(lat1); | |
double latB=Math.toRadians(lat2); | |
double y = Math.sin(dLon) * Math.cos(latB); | |
double x = Math.cos(latA) * Math.sin(latB) - Math.sin(latA) * Math.cos(latB) * Math.cos(dLon); | |
double bearing = Math.toDegrees(Math.atan2(y, x)); | |
return bearing; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment