### Question:
SphereBody extends GeographicBody3D { @Override public Vector3d convertToModel(GeographicPosition inPos, Vector3d modelCenter) { double φ = Math.toRadians(inPos.getLatLonAlt().getLatD()); double λ = Math.toRadians(inPos.getLatLonAlt().getLonD()); double cosφ = Math.cos(φ); double sinφ = Math.sin(φ); double sinλ = Math.sin(λ); double cosλ = Math.cos(λ); double radius = getShape().getRadius(); double x = radius * cosφ * cosλ; double y = radius * cosφ * sinλ; double z = radius * sinφ; if (inPos.getLatLonAlt().getAltM() > 0) { if (inPos.getLatLonAlt().getAltitudeReference() == ReferenceLevel.ELLIPSOID) { double scalar = 1.0 + inPos.getLatLonAlt().getAltM() / radius; return new Vector3d(x * scalar, y * scalar, z * scalar); } else if (inPos.getLatLonAlt().getAltitudeReference() == ReferenceLevel.ORIGIN) { return new Vector3d(x, y, z).getNormalized().multiply(inPos.getLatLonAlt().getAltM()); } else { throw new UnexpectedEnumException(inPos.getLatLonAlt().getAltitudeReference()); } } return new Vector3d(x - modelCenter.getX(), y - modelCenter.getY(), z - modelCenter.getZ()); } SphereBody(double radius); static Vector3d getDefaultNormalAtPosition(GeographicPosition inPos); @Override Vector3d convertToModel(GeographicPosition inPos, Vector3d modelCenter); @Override GeographicPosition convertToPosition(Vector3d inPos, ReferenceLevel altReference); @Override Vector3d getNormalAtPosition(GeographicPosition inPos); @Override Sphere getShape();  }### Answer:
@Test public void testConvertToModel() { double r = 5.3; SphereBody body = new SphereBody(r); Assert.assertEquals(new Vector3d(r, 0., 0.), body.convertToModel(new GeographicPosition(LatLonAlt.createFromDegrees(0., 0.)), Vector3d.ORIGIN)); Assert.assertEquals(new Vector3d(0., r, 0.), body.convertToModel(new GeographicPosition(LatLonAlt.createFromDegrees(0., 90.)), Vector3d.ORIGIN)); Assert.assertEquals(new Vector3d(-r, 0., 0.), body.convertToModel(new GeographicPosition(LatLonAlt.createFromDegrees(0., 180.)), Vector3d.ORIGIN)); Assert.assertEquals(new Vector3d(0., -r, 0.), body.convertToModel(new GeographicPosition(LatLonAlt.createFromDegrees(0., 270.)), Vector3d.ORIGIN)); Assert.assertEquals(new Vector3d(0., -r, 0.), body.convertToModel(new GeographicPosition(LatLonAlt.createFromDegrees(0., -90.)), Vector3d.ORIGIN)); Assert.assertEquals(new Vector3d(-r, 0., 0.), body.convertToModel(new GeographicPosition(LatLonAlt.createFromDegrees(0., -180.)), Vector3d.ORIGIN)); Assert.assertEquals(new Vector3d(0., 0., r), body.convertToModel(new GeographicPosition(LatLonAlt.createFromDegrees(90., 0.)), Vector3d.ORIGIN)); Assert.assertEquals(new Vector3d(0., 0., -r), body.convertToModel(new GeographicPosition(LatLonAlt.createFromDegrees(-90., 0.)), Vector3d.ORIGIN)); Assert.assertEquals(new Vector3d(r / 2., r / 2., r / Math.sqrt(2)), body.convertToModel(new GeographicPosition(LatLonAlt.createFromDegrees(45., 45.)), Vector3d.ORIGIN)); }