Expand description
Pure navigation math.
The bottom layer of the navigation core: great circle and rhumb line sailings, cross-track error, the wind triangle, the current triangle, VMG and laylines, and a boat’s own performance polar. Every item here is a plain function of its arguments – no clock, no I/O, no state, no dependencies. That is what lets the layers above replay a recorded log deterministically.
§Units and conventions
There is one convention throughout, and it is worth reading once:
- Angles are degrees, never radians. Radians exist only inside a function body.
- Bearings, headings and courses are degrees true,
0.0..360.0, clockwise from north. Magnetic variation is deliberately not handled here: it is a property of a place and a date, so it belongs to the layer that knows where and when the vessel is. - Relative angles (true and apparent wind angle) are signed,
-180.0..=180.0, measured from the bow, positive to starboard. - Distances are nautical miles, speeds are knots.
- Cross-track error is positive when the vessel is to starboard of the track.
Nothing enforces these at the type level. Newtypes were considered
and rejected: they make formulae meant to be read against a textbook
harder to read, without preventing the mistakes this crate actually
risks. Function and field names carry the unit instead –
distance_nm, bearing_deg, speed_kn.
§Earth model
A sphere of radius EARTH_RADIUS_NM, not the WGS84 ellipsoid. Over
the distance of a single leg, the difference is well under the error
in the fix that starts the leg. One consequence worth noting: one
degree of latitude comes out as 60.04 NM rather than exactly 60,
because the nautical mile is a fixed 1852 m while a minute of arc on
the mean sphere is 1853.25 m.
Re-exports§
pub use position::Position;
Modules§
- angle
- Angle normalisation.
- current
- The current triangle: deriving set and drift, and steering to beat them.
- great_
circle - Great circle sailing – the shortest path between two positions.
- polar
- Boat performance polars, and the tactical numbers built on one.
- position
- A geographic position.
- rhumb
- Rhumb line (loxodrome) sailing – the path of constant bearing.
- sailing
- Velocity made good and laylines.
- track
- Position relative to a route leg: cross-track error and along-track distance.
- wind
- The wind triangle: converting between apparent and true wind.
Constants§
- EARTH_
RADIUS_ NM - Mean radius of the earth in nautical miles.
- METRES_
PER_ FOOT - The international foot, exactly – a fixed definition, like
METRES_PER_NM. Distance and speed stay nautical miles and knots throughout this crate (see “Units and conventions” above); this constant exists for converting a length or depth to feet when a display preference requires it. - METRES_
PER_ NM - The international definition of the nautical mile, exactly 1852 m.
Exported so other crates converting a
distance_nmresult into metres for the wire (Signal K’s resources are metric) use this value instead of restating the literal. - METRES_
PER_ STATUTE_ MILE - The statute mile, exactly –
5280×METRES_PER_FOOT, a fixed international definition. Distinct fromMETRES_PER_NM: used for an imperial (non-nautical) display preference, as opposed to a nautical-imperial one.