Struct Longitude

Geodetic longitude in the closed interval [-pi,+pi] radians.

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

The equivalent degree domain is [-180,+180]. Both antimeridian endpoint representations are accepted by construction. normalized maps the positive endpoint to the unique half-open representation from -pi inclusive to +pi exclusive. .init is the prime meridian.

Checked factories return false for non-finite or out-of-domain input; throwing factories throw GeodesyValueException for the same inputs.

Properties

NameTypeDescription
asAngle[get] Angle!TReturn the same angular value as a general Angle!T.
degrees[get] TLongitude in degrees.
normalized[get] LongitudeReturn the unique representation from -pi inclusive to +pi exclusive.
radians[get] TLongitude in radians.

Methods

NameDescription
fromDegrees (degrees) Construct a longitude from degrees.
fromRadians (radians) Construct a longitude from radians.
tryFromDegrees (degrees, result) Construct a longitude from degrees without throwing.
tryFromRadians (radians, result) Construct a longitude from radians without throwing.

Example

Example constructing and normalizing a longitude.

import geodesy;

const eastAntimeridian = Longitude!double.fromDegrees(180.0);
assert(eastAntimeridian.degrees == 180.0);
assert(eastAntimeridian.normalized.degrees == -180.0);

Longitude!double checked;
assert(!Longitude!double.tryFromDegrees(181.0, checked));