public double greatCircleAzimuth(Location location){
  if (location == null) {
    throw new IllegalArgumentException(Logger.logMessage(Logger.ERROR,"Location","greatCircleAzimuth","missingLocation"));
  }
  double lat1=Math.toRadians(this.latitude);
  double lon1=Math.toRadians(this.longitude);
  double lat2=Math.toRadians(location.latitude);
  double lon2=Math.toRadians(location.longitude);
  if (lat1 == lat2 && lon1 == lon2) {
    return 0;
  }
  if (lon1 == lon2) {
    return lat1 > lat2 ? 180 : 0;
  }
  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) ? 0 : Math.toDegrees(azimuthRadians);
}

public double greatCircleAzimuth ( Location location ) { if ( location == null ) { throw new IllegalArgumentException ( Logger . logMessage ( Logger . ERROR , "Location" , "greatCircleAzimuth" , "missingLocation" ) ) ; } double lat1 = Math . toRadians ( this . latitude ) ; double lon1 = Math . toRadians ( this . longitude ) ; double lat2 = Math . toRadians ( location . latitude ) ; double lon2 = Math . toRadians ( location . longitude ) ; if ( lat1 == lat2 && lon1 == lon2 ) { return 0 ; } if ( lon1 == lon2 ) { return lat1 > lat2 ? 180 : 0 ; } 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 ) ? 0 : Math . toDegrees ( azimuthRadians ) ; }
computes the azimuth angle ( clockwise from north ) for the great circle path between this location and a specified location . this angle can be used as the starting azimuth for a great circle path beginning at this location , and passing through the specified location . this function uses a spherical model , not elliptical .
