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.
- Rate
OfTurn - 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.