-#include <simgear/math/polar3d.hxx>
-
-
-// sgGeocToGeod(lat_geoc, radius, *lat_geod, *alt, *sea_level_r)
-// INPUTS:
-// lat_geoc Geocentric latitude, radians, + = North
-// radius C.G. radius to earth center (meters)
-//
-// OUTPUTS:
-// lat_geod Geodetic latitude, radians, + = North
-// alt C.G. altitude above mean sea level (meters)
-// sea_level_r radius from earth center to sea level at
-// local vertical (surface normal) of C.G. (meters)
-
-void sgGeocToGeod( double lat_geoc, double radius, double
- *lat_geod, double *alt, double *sea_level_r );
-
-
-// sgGeodToGeoc( lat_geod, alt, *sl_radius, *lat_geoc )
-// INPUTS:
-// lat_geod Geodetic latitude, radians, + = North
-// alt C.G. altitude above mean sea level (meters)
-//
-// OUTPUTS:
-// sl_radius SEA LEVEL radius to earth center (meters)
-// (add Altitude to get true distance from earth center.
-// lat_geoc Geocentric latitude, radians, + = North
-//
-
-void sgGeodToGeoc( double lat_geod, double alt, double *sl_radius,
- double *lat_geoc );
-
-
-// convert a geodetic point lon(radians), lat(radians), elev(meter) to
-// a cartesian point
-
-inline Point3D sgGeodToCart(const Point3D& geod) {
- double gc_lon, gc_lat, sl_radius;
-
- // printf("A geodetic point is (%.2f, %.2f, %.2f)\n",
- // geod[0], geod[1], geod[2]);
-
- gc_lon = geod.lon();
- sgGeodToGeoc(geod.lat(), geod.radius(), &sl_radius, &gc_lat);
-
- // printf("A geocentric point is (%.2f, %.2f, %.2f)\n", gc_lon,
- // gc_lat, sl_radius+geod[2]);
-
- Point3D pp = Point3D( gc_lon, gc_lat, sl_radius + geod.radius());
- return sgPolarToCart3d(pp);
+#include "SGMath.hxx"
+
+// Compatibility header.
+// Please use the SGGeodesy and SGMath functions directly.
+
+/**
+ * Convert from geodetic coordinates to geocentric coordinates.
+ * WARNING: this function is non-reversible. Due to the fact that
+ * "up" is a different direction for geocentric and geodetic frames,
+ * you can not simply add your "alt" parameter to the "sl_radius"
+ * result and get back (via sgGeodToGeoc()) to the coordinates you
+ * started with. The error under normal conditions will be of
+ * centimeter order; whether that is important or not is application
+ * dependent. Consider using sgGeodToCart() instead.
+ *
+ * @param lat_geod (in) Geodetic latitude, radians, + = North
+ * @param alt (in) C.G. altitude above mean sea level (meters)
+ * @param sl_radius (out) SEA LEVEL radius to earth center (meters)
+ * @param lat_geoc (out) Geocentric latitude, radians, + = North
+ */
+inline void sgGeodToGeoc(double lat_geod, double alt,
+ double *sl_radius, double *lat_geoc)
+{
+ SGVec3<double> cart;
+ SGGeod geod = SGGeod::fromRadM(0, lat_geod, alt);
+ SGGeodesy::SGGeodToCart(geod, cart);
+ SGGeoc geoc;
+ SGGeodesy::SGCartToGeoc(cart, geoc);
+ *lat_geoc = geoc.getLatitudeRad();
+ *sl_radius = SGGeodesy::SGGeodToSeaLevelRadius(geod);