Skip to content

Instantly share code, notes, and snippets.

View aaryadev's full-sized avatar
💭
I may be slow to respond.

Aaryadev aaryadev

💭
I may be slow to respond.
View GitHub Profile
@aaryadev
aaryadev / gpsbearing
Created February 28, 2015 06:55
bearing between 2 gps location
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;
}