Function tryGeodeticToGeocentric

Convert a geodetic coordinate to geocentric Cartesian coordinates.

bool tryGeodeticToGeocentric(T)(
  const GeodeticCoordinate!T source,
  const Ellipsoid!T ellipsoid,
  out GeocentricCoordinate!T result
) pure nothrow @nogc @safe
if (isGeodesyScalar!T);

Implements the forward direction of EPSG coordinate operation method 9602 (Geographic/geocentric conversions). Longitude is interpreted relative to the prime meridian defining the geocentric X axis; conventional EPSG geocentric systems use Greenwich.

Ellipsoidal height and ellipsoid axes must use the same linear unit. The returned X/Y/Z components use that unit. No datum transformation is performed.

Parameters

NameDescription
source Finite geodetic latitude, longitude, and ellipsoidal height.
ellipsoid Valid spherical or oblate reference ellipsoid in the same linear unit as source.ellipsoidalHeight.
result Receives the geocentric coordinate on success.

Returns

true when a finite representable Cartesian result is produced; false for an invalid ellipsoid or when finite inputs overflow or otherwise produce a non-finite result in scalar type T.

No allocation is performed.

Example

Example using bool tryGeodeticToGeocentric(T)( const GeodeticCoordinate!T source, const Ellipsoid!T ellipsoid, out Geocent.

import geodesy;

const source = GeodeticCoordinate!double.fromComponents(
    Latitude!double.fromDegrees(53.0),
    Longitude!double.fromDegrees(2.0),
    73.0);

const xyz = geodeticToGeocentric(source, wgs84!double());
assert(xyz.x > 0.0);

GeocentricCoordinate!double checked;
assert(tryGeodeticToGeocentric(source, wgs84!double(), checked));