Location { 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); } Location();  Location(double latitude, double longitude);  Location(Location location); static Location fromDegrees(double latitudeDegrees, double longitudeDegrees); static Location fromRadians(double latitudeRadians, double longitudeRadians); static Location fromTimeZone(TimeZone timeZone); static double normalizeLatitude(double degrees); static double normalizeLongitude(double degrees); static double clampLatitude(double degrees); static double clampLongitude(double degrees); static boolean locationsCrossAntimeridian(List<? extends Location> locations); @Override boolean equals(Object o); @Override int hashCode(); @Override String toString(); Location set(double latitude, double longitude); Location set(Location location); Location interpolateAlongPath(Location endLocation, @WorldWind.PathType int pathType, double amount,
                                         Location result); double greatCircleAzimuth(Location location); double greatCircleDistance(Location location); Location greatCircleLocation(double azimuthDegrees, double distanceRadians, Location result); double rhumbAzimuth(Location location); double rhumbDistance(Location location); Location rhumbLocation(double azimuthDegrees, double distanceRadians, Location result); double linearAzimuth(Location location); double linearDistance(Location location); Location linearLocation(double azimuthDegrees, double distanceRadians, Location result); public double latitude; public double longitude; }
@Test public void testLinearAzimuth() throws Exception { Location begin = Location.fromDegrees(0d, 0d); Location end = Location.fromDegrees(1d, Math.sqrt(3d)); double azimuth = begin.linearAzimuth(end); assertEquals("linear azimuth", 60d, azimuth, TOLERANCE); }
@Ignore("NaN behavior TBD") @Test public void testLinearAzimuth_WithNaN() throws Exception { Location begin = new Location(Double.NaN, Double.NaN); Location end = new Location(34.2, -119.2); double azimuth = begin.linearAzimuth(end); assertTrue("expecting NaN", Double.isNaN(azimuth)); }