public double linearAzimuth(Location location){
  if (location == null) {
    throw new IllegalArgumentException(Logger.logMessage(Logger.ERROR,"Location","linearAzimuth","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;
  }
  double dLon=lon2 - lon1;
  double dPhi=lat2 - lat1;
  if (Math.abs(dLon) > Math.PI) {
    dLon=dLon > 0 ? -(2 * Math.PI - dLon) : (2 * Math.PI + dLon);
  }
  double azimuthRadians=Math.atan2(dLon,dPhi);
  return Double.isNaN(azimuthRadians) ? 0 : Math.toDegrees(azimuthRadians);
}

public double linearAzimuth ( Location location ) { if ( location == null ) { throw new IllegalArgumentException ( Logger . logMessage ( Logger . ERROR , "Location" , "linearAzimuth" , "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 ; } double dLon = lon2 - lon1 ; double dPhi = lat2 - lat1 ; if ( Math . abs ( dLon ) > Math . PI ) { dLon = dLon > 0 ? - ( 2 * Math . PI - dLon ) : ( 2 * Math . PI + dLon ) ; } double azimuthRadians = Math . atan2 ( dLon , dPhi ) ; return Double . isNaN ( azimuthRadians ) ? 0 : Math . toDegrees ( azimuthRadians ) ; }
computes the azimuth angle ( clockwise from north ) for the linear path between this location and a specified location . this angle can be used as the starting azimuth for a linear path beginning at this location , and passing through the specified location . this function uses a flat - earth approximation proximal to this location .
