public static double computeHeading ( IGeoPoint from , IGeoPoint to ) { // http://williams.best.vwh.net/avform.htm#Crs double fromLat = toRadians ( from . getLatitude ( ) ) ; double fromLng = toRadians ( from . getLongitude ( ) ) ; double toLat = toRadians ( to . getLatitude ( ) ) ; double toLng = toRadians ( to . getLongitude ( ) ) ; double dLng = toLng - fromLng ; double heading = atan2 ( sin ( dLng ) * cos ( toLat ) , cos ( fromLat ) * sin ( toLat ) - sin ( fromLat ) * cos ( toLat ) * cos ( dLng ) ) ; return wrap ( toDegrees ( heading ) , - 180 , 180 ) ; }
Returns the heading from one LatLng to another LatLng . Headings are expressed in degrees clockwise from North within the range [ - 180 180 ) .