### Question:
SphericalMercatorProjection { public static double[] geodeticToEcef(double[] geodetic) { double[] ecef = new double[3]; double latitude = geodetic[0]; double longitude = geodetic[1]; double altitude = geodetic[2]; double n = EARTH_RADIUS / Math.sqrt(1 - E2 * Math.sin(latitude) * Math.sin(latitude)); ecef[0] = (n + altitude) * Math.cos(latitude) * Math.cos(longitude); ecef[1] = (n + altitude) * Math.cos(latitude) * Math.sin(longitude); ecef[2] = (n * (1 - E2) + altitude) * Math.sin(latitude); return ecef; }  static double yToLatitude(double y); static double xToLongitude(double x); static double latitudeToY(double latitude); static double longitudeToX(double longitude); static Location ecefToLocation(double[] ecef); static double[] ecefToGeodetic(double[] ecef); static double[] locationToEcef(Location location); static double[] geodeticToEcef(double[] geodetic); static final double EARTH_RADIUS; }### Answer:
@Test public void geodeticToEcef_location_accurateEcef() { double[] expectedCenter = new double[]{3786292.474596871, 890822.9600122868, 5037857.368752121}; double[] geodetic = new double[]{ Math.toRadians(LocationTest.SOCCER_FIELD_CENTER.getLatitude()), Math.toRadians(LocationTest.SOCCER_FIELD_CENTER.getLongitude()), Math.toRadians(LocationTest.SOCCER_FIELD_CENTER.getAltitude()) }; double[] actualCenter = SphericalMercatorProjection.geodeticToEcef(geodetic); assertEquals(expectedCenter[0], actualCenter[0], 1); assertEquals(expectedCenter[1], actualCenter[1], 1); assertEquals(expectedCenter[2], actualCenter[2], 1); }