Location { public Location greatCircleLocation(double azimuthDegrees, double distanceRadians, Location result) { if (result == null) { throw new IllegalArgumentException( Logger.logMessage(Logger.ERROR, "Location", "greatCircleLocation", "missingResult")); } if (distanceRadians == 0) { result.latitude = this.latitude; result.longitude = this.longitude; return result; } double latRadians = Math.toRadians(this.latitude); double lonRadians = Math.toRadians(this.longitude); double azimuthRadians = Math.toRadians(azimuthDegrees); double cosLat = Math.cos(latRadians); double sinLat = Math.sin(latRadians); double cosAzimuth = Math.cos(azimuthRadians); double sinAzimuth = Math.sin(azimuthRadians); double sinDistance = Math.sin(distanceRadians); double cosDistance = Math.cos(distanceRadians); double endLatRadians = Math.asin(sinLat * cosDistance + cosLat * sinDistance * cosAzimuth); double endLonRadians = lonRadians + Math.atan2( sinDistance * sinAzimuth, cosLat * cosDistance - sinLat * sinDistance * cosAzimuth); if (Double.isNaN(endLatRadians) || Double.isNaN(endLonRadians)) { result.latitude = this.latitude; result.longitude = this.longitude; } else { result.latitude = normalizeLatitude(Math.toDegrees(endLatRadians)); result.longitude = normalizeLongitude(Math.toDegrees(endLonRadians)); } return result; } 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 testGreatCircleLocation_NorthPole() throws Exception { Location origin = new Location(); Location result = new Location(); origin.greatCircleLocation(0, Math.toRadians(90), result); assertEquals("north pole latitude", 90, result.latitude, Double.MIN_VALUE); }
@Test public void testGreatCircleLocation_SouthPole() throws Exception { Location origin = new Location(); Location result = new Location(); origin.greatCircleLocation(180, Math.toRadians(90), result); assertEquals("south pole latitude", -90, result.latitude, Double.MIN_VALUE); }