public static double bearing(Point p1,Point p2){
  double degrees2radians=Math.PI / 180;
  double radians2degrees=180 / Math.PI;
  Position coordinates1=p1.getCoordinates();
  Position coordinates2=p2.getCoordinates();
  double lon1=degrees2radians * coordinates1.getLongitude();
  double lon2=degrees2radians * coordinates2.getLongitude();
  double lat1=degrees2radians * coordinates1.getLatitude();
  double lat2=degrees2radians * coordinates2.getLatitude();
  double a=Math.sin(lon2 - lon1) * Math.cos(lat2);
  double b=Math.cos(lat1) * Math.sin(lat2) - Math.sin(lat1) * Math.cos(lat2) * Math.cos(lon2 - lon1);
  return radians2degrees * Math.atan2(a,b);
}

public static double bearing ( Point p1 , Point p2 ) { double degrees2radians = Math . PI / 180 ; double radians2degrees = 180 / Math . PI ; Position coordinates1 = p1 . getCoordinates ( ) ; Position coordinates2 = p2 . getCoordinates ( ) ; double lon1 = degrees2radians * coordinates1 . getLongitude ( ) ; double lon2 = degrees2radians * coordinates2 . getLongitude ( ) ; double lat1 = degrees2radians * coordinates1 . getLatitude ( ) ; double lat2 = degrees2radians * coordinates2 . getLatitude ( ) ; double a = Math . sin ( lon2 - lon1 ) * Math . cos ( lat2 ) ; double b = Math . cos ( lat1 ) * Math . sin ( lat2 ) - Math . sin ( lat1 ) * Math . cos ( lat2 ) * Math . cos ( lon2 - lon1 ) ; return radians2degrees * Math . atan2 ( a , b ) ; }
takes two points and finds the geographic bearing between them .
