Struct Geodesic
Prepared direct/inverse geodesic solver for one reference ellipsoid.
struct Geodesic(T)
if (isGeodesyScalar!T);
Supported ellipsoids satisfy a > 0 and -0.01 <= f <= 0.01; no Earth-size
restriction applies. Linear distances use the same unit as the ellipsoid
semi-major axis. Exact spheres and supported oblate/prolate ellipsoids are handled.
is invalid. Prepare a solver once and reuse it for multiple direct
or inverse operations.
Direct operations accept finite signed distance. Negative distance follows the same oriented geodesic backward. Inverse operations return the shortest geodesic and canonical coincident-point semantics.
Properties
| Name | Type | Description |
|---|---|---|
ellipsoid[get]
|
Ellipsoid!T | The ellipsoid used by this solver. |
isSphere[get]
|
bool | True when the prepared ellipsoid is exactly spherical. |
isValid[get]
|
bool | True when this solver represents the supported ellipsoid profile. |
Methods
| Name | Description |
|---|---|
direct
(start, initialAzimuth, distance)
|
Solve the direct geodesic problem with throwing failure semantics. |
fromEllipsoid
(ellipsoid)
|
Prepare a reusable direct/inverse solver. |
inverse
(start, end)
|
Solve the shortest inverse geodesic problem with throwing semantics. |
tryDirect
(start, initialAzimuth, distance, result)
|
Find a destination from a start position, bearing and distance. |
tryDirect
(start, initialAzimuth, distance, result, quantities)
|
Solve the direct geodesic and its advanced segment quantities. |
tryFromEllipsoid
(ellipsoid, result)
|
Prepare a reusable direct/inverse solver without throwing. |
tryInverse
(start, end, result)
|
Find the shortest surface distance and bearings between two positions. |
tryInverse
(start, end, result, quantities)
|
Solve the shortest inverse geodesic and its advanced segment quantities. |
Example
Example using struct Geodesic(T) if (isGeodesyScalar!T).
import geodesy;
const solver = Geodesic!double .fromEllipsoid(wgs84!double());
const vienna = GeographicCoordinate!double .fromComponents(
Latitude!double .fromDegrees(48.20849),
Longitude!double .fromDegrees(16.37208));
const newYork = GeographicCoordinate!double .fromComponents(
Latitude!double .fromDegrees(40.7128),
Longitude!double .fromDegrees(-74.0060));
const inverse = solver .inverse(vienna, newYork);
const direct = solver .direct(
vienna, inverse .initialAzimuth, inverse .distance);
assert(inverse .distance > 0.0);
assert(direct .position .latitude .degrees < 41.0);