Skip to main content

Module units

Module units 

Source
Expand description

Angles, distances, speeds and rates of turn as types.

A function taking (f64, f64) cannot distinguish knots from m/s; these types can.

Internally distances are nautical miles, speeds knots, rates of turn °/min; construct and read in any unit.

§Example

use kinavis_kernel::{Distance, KernelError, Speed};
use core::time::Duration;

let leg = Distance::from_nautical_miles(12.0)?;
assert_eq!(format!("{:.0}", leg.metres()), "22224");
assert_eq!(format!("{:.0}", leg.cables()), "120");

let speed = Speed::from_knots(8.0)?;
let elapsed = speed.time_to_cover(leg)?;
assert_eq!(elapsed.as_secs(), 5400); // an hour and a half

assert_eq!(speed.distance_covered(elapsed).nautical_miles(), 12.0);

Structs§

Angle
Angular magnitude in degrees.
Distance
Distance, stored in nautical miles.
RateOfTurn
Rate of turn in °/min, as shown by the ROT indicator.
Speed
Speed, stored in knots. Negative is sternway.

Constants§

CABLES_PER_NAUTICAL_MILE
Cables per nautical mile.
METRES_PER_FATHOM
Metres per fathom (6 ft).
METRES_PER_FOOT
Metres per foot.
METRES_PER_NAUTICAL_MILE
Metres per international nautical mile.

Functions§

duration_from_hours
Duration from hours.
hours
Duration in hours.