Globe { public double getRadiusAt(double latitude, double longitude) { double sinLat = Math.sin(Math.toRadians(latitude)); double ec2 = this.ellipsoid.eccentricitySquared(); double rpm = this.ellipsoid.semiMajorAxis() / Math.sqrt(1 - ec2 * sinLat * sinLat); return rpm * Math.sqrt(1 + (ec2 * ec2 - 2 * ec2) * sinLat * sinLat); } Globe(Ellipsoid ellipsoid, GeographicProjection projection); Ellipsoid getEllipsoid(); void setEllipsoid(Ellipsoid ellipsoid); double getEquatorialRadius(); double getPolarRadius(); double getRadiusAt(double latitude, double longitude); double getEccentricitySquared(); ElevationModel getElevationModel(); void setElevationModel(ElevationModel elevationModel); GeographicProjection getProjection(); void setProjection(GeographicProjection projection); Vec3 geographicToCartesian(double latitude, double longitude, double altitude, Vec3 result); Vec3 geographicToCartesianNormal(double latitude, double longitude, Vec3 result); Matrix4 geographicToCartesianTransform(double latitude, double longitude, double altitude, Matrix4 result); float[] geographicToCartesianGrid(Sector sector, int numLat, int numLon, float[] height, float verticalExaggeration,
                                             Vec3 origin, float[] result, int offset, int rowStride); float[] geographicToCartesianBorder(Sector sector, int numLat, int numLon, float height,
                                               Vec3 origin, float[] result); Position cartesianToGeographic(double x, double y, double z, Position result); Matrix4 cartesianToLocalTransform(double x, double y, double z, Matrix4 result); @SuppressWarnings("UnnecessaryLocalVariable") double horizonDistance(double height); boolean intersect(Line line, Vec3 result);  }
@Test public void testGetRadiusAt() throws Exception { for (double lat = -90; lat <= 90; lat += 1.0) { double radiusExpected = computeRadiusOfEllipsoid(lat); double radiusActual = globe.getRadiusAt(lat, 0); assertEquals(Double.toString(lat), radiusExpected, radiusActual, 1.0e-8); } }