public static Angle greatCircleAzimuth(LatLon p1,LatLon p2){
  if ((p1 == null) || (p2 == null)) {
    throw new IllegalArgumentException("Lat Lon Is Null");
  }
  double lat1=p1.getLatitude().radians;
  double lon1=p1.getLongitude().radians;
  double lat2=p2.getLatitude().radians;
  double lon2=p2.getLongitude().radians;
  if (lat1 == lat2 && lon1 == lon2)   return Angle.ZERO;
  if (lon1 == lon2)   return lat1 > lat2 ? Angle.POS180 : Angle.ZERO;
  double y=Math.cos(lat2) * Math.sin(lon2 - lon1);
  double x=Math.cos(lat1) * Math.sin(lat2) - Math.sin(lat1) * Math.cos(lat2) * Math.cos(lon2 - lon1);
  double azimuthRadians=Math.atan2(y,x);
  return Double.isNaN(azimuthRadians) ? Angle.ZERO : Angle.fromRadians(azimuthRadians);
}

public static Angle greatCircleAzimuth ( LatLon p1 , LatLon p2 ) { if ( ( p1 == null ) || ( p2 == null ) ) { throw new IllegalArgumentException ( "Lat Lon Is Null" ) ; } double lat1 = p1 . getLatitude ( ) . radians ; double lon1 = p1 . getLongitude ( ) . radians ; double lat2 = p2 . getLatitude ( ) . radians ; double lon2 = p2 . getLongitude ( ) . radians ; if ( lat1 == lat2 && lon1 == lon2 ) return Angle . ZERO ; if ( lon1 == lon2 ) return lat1 > lat2 ? Angle . POS180 : Angle . ZERO ; double y = Math . cos ( lat2 ) * Math . sin ( lon2 - lon1 ) ; double x = Math . cos ( lat1 ) * Math . sin ( lat2 ) - Math . sin ( lat1 ) * Math . cos ( lat2 ) * Math . cos ( lon2 - lon1 ) ; double azimuthRadians = Math . atan2 ( y , x ) ; return Double . isNaN ( azimuthRadians ) ? Angle . ZERO : Angle . fromRadians ( azimuthRadians ) ; }
computes the azimuth angle ( clockwise from north ) that points from the first location to the second location . this angle can be used as the starting azimuth for a great circle arc that begins at the first location , and passes through the second location .
