Struct Ellipsoid

A spherical or oblate reference ellipsoid stored canonically as semi-major axis a and flattening f.

struct Ellipsoid(T)
  
if (isGeodesyScalar!T);

The semi-major axis defines the caller-selected linear unit. Operations combining an ellipsoid with heights or Cartesian coordinates require those values to use the same linear unit. Ellipsoid.init is intentionally invalid so accidental default construction cannot silently select a plausible Earth model.

General construction accepts finite a > 0 and 0 <= f < 1. fromInverseFlattening requires a finite inverse flattening greater than one; construct spheres explicitly with sphere.

Checked factories return false for invalid parameters. Their throwing peers throw GeodesyValueException. Derived properties do not allocate.

Properties

NameTypeDescription
firstEccentricitySquared[get] TFirst eccentricity squared e².
flattening[get] TFlattening f.
inverseFlattening[get] TDerived inverse flattening 1/f; infinity for a sphere.
isValid[get] boolTrue when this value represents a supported spherical or oblate ellipsoid.
secondEccentricitySquared[get] TSecond eccentricity squared (e′²).
semiMajorAxis[get] TSemi-major axis a in the ellipsoid linear unit.
semiMinorAxis[get] TDerived semi-minor axis b = a(1-f).
thirdFlattening[get] TThird flattening n = f/(2-f).

Methods

NameDescription
fromAxes (semiMajorAxis, semiMinorAxis) Construct from semi-major and semi-minor axes or throw on invalid parameters.
fromFlattening (semiMajorAxis, flattening) Construct from semi-major axis and flattening or throw on invalid parameters.
fromInverseFlattening (semiMajorAxis, inverseFlattening) Construct from semi-major axis and inverse flattening or throw on invalid parameters.
sphere (radius) Construct a sphere or throw when the radius is invalid.
tryFromAxes (semiMajorAxis, semiMinorAxis, result) Construct from semi-major and semi-minor axes without throwing.
tryFromFlattening (semiMajorAxis, flattening, result) Construct from semi-major axis and flattening without throwing.
tryFromInverseFlattening (semiMajorAxis, inverseFlattening, result) Construct from semi-major axis and inverse flattening without throwing.
trySphere (radius, result) Construct a sphere without throwing; radius must be finite and positive.

Example

Example constructing Earth and spherical ellipsoids.

import geodesy;

const earth = wgs84!double();
assert(earth.isValid);
assert(earth.semiMajorAxis == 6_378_137.0);

const sphere = Ellipsoid!double.sphere(6_371_000.0);
assert(sphere.flattening == 0.0);
assert(sphere.semiMinorAxis == sphere.semiMajorAxis);

assert(!Ellipsoid!double.init.isValid);