Skip to content

nmeasim::core::geo

namespace nmeasim::core::geo · Library API

Geographic positions and geodesics on the WGS 84 ellipsoid, part of the nmeasim::core library.

It holds the Position type the whole simulator uses, the direct and inverse geodesic problems, and the leg geometry the autopilot sentences and Signal K course paths report. All angles are in decimal degrees, all distances in metres. Bearings are measured clockwise from true north and normalised to the half-open range [0, 360).

See also

  • GeographicLib::Geodesic

Types

Type Description
InverseSolution Result of the inverse geodesic problem between two positions.
LegSolution Bearings and distances of a leg and of the vessel relative to it.
Position A geographic position on the WGS 84 ellipsoid, without height.

Summary

Functions

Name Description
normalize_bearing() Normalises an angle in degrees to the half-open range [0, 360).
inverse() Solves the inverse geodesic problem: the distance and bearings from from to to.
direct() Solves the direct geodesic problem: the position reached by travelling a distance along a geodesic from a starting point.
solve_leg() Solves the leg from origin to destination for a vessel at vessel.

Functions

normalize_bearing()

double normalize_bearing(double bearing_deg) noexcept

Normalises an angle in degrees to the half-open range [0, 360).

Parameters

Name Type Description
bearing_deg double Any finite angle in degrees; negative values count anticlockwise.

Returns double: The equivalent angle in [0, 360), never -0.0 and never exactly 360. A non-finite argument gives NaN.

Declared in src/core/include/nmeasim/core/geo/geodesic.hpp:51 · defined in src/core/src/geo/geodesic.cpp:13

inverse()

InverseSolution inverse(Position from, Position to)

Solves the inverse geodesic problem: the distance and bearings from from to to.

Parameters

Name Type Description
from Position Start of the path; its latitude must be in [-90, 90].
to Position End of the path; its latitude must be in [-90, 90].

Returns InverseSolution: Distance in metres and initial and final true bearings in [0, 360).

See also

  • GeographicLib::Geodesic::Inverse

Declared in src/core/include/nmeasim/core/geo/geodesic.hpp:59 · defined in src/core/src/geo/geodesic.cpp:26

direct()

Position direct(Position from, double bearing_deg, double distance_m)

Solves the direct geodesic problem: the position reached by travelling a distance along a geodesic from a starting point.

Parameters

Name Type Description
from Position Starting position; its latitude must be in [-90, 90].
bearing_deg double Initial true bearing at from, in degrees; any value is accepted.
distance_m double Distance to travel along the ellipsoid; a negative distance travels backwards along the same geodesic.

Returns Position: The position reached, with its longitude reduced to [-180, 180].

See also

  • GeographicLib::Geodesic::Direct

Declared in src/core/include/nmeasim/core/geo/geodesic.hpp:70 · defined in src/core/src/geo/geodesic.cpp:37

solve_leg()

LegSolution solve_leg(Position origin, Position destination, Position vessel)

Solves the leg from origin to destination for a vessel at vessel.

Bearings and the distances to the destination use the WGS 84 geodesic. The cross-track and along-track distances use the spherical great-circle formulas on the mean earth radius, accurate to well under one percent for legs of coastal length. A vessel exactly at the origin has zero cross-track and along-track distances.

Parameters

Name Type Description
origin Position Start of the leg, normally the vessel's position when the destination was set.
destination Position The waypoint the leg leads to.
vessel Position Current position of the vessel.

Returns LegSolution: The leg geometry. When origin and destination coincide the leg has no direction and the cross-track and along-track distances are measured against whatever bearing the geodesic solution reports for a zero-length path.

Declared in src/core/include/nmeasim/core/geo/route.hpp:49 · defined in src/core/src/geo/route.cpp:30