pub struct Direction<F: Frame> { /* private fields */ }Expand description
Direction in [0°, 360°), tagged with its reference frame.
Courses and bearings share this type: within a frame they are the same quantity. The type prevents mixing frames.
Implementations§
Source§impl<F: Frame> Direction<F>
impl<F: Frame> Direction<F>
Sourcepub fn new(degrees: f64) -> Result<Self>
pub fn new(degrees: f64) -> Result<Self>
Direction from a value in [0.0, 360.0]; 360.0 maps to 0.0.
Out-of-range values are rejected, not wrapped: 400° is more likely a
typo or unit error than 040°. Use Direction::wrap to wrap.
§Errors
KernelError::NotFinite for NaN or infinity;
KernelError::OutOfRange outside [0.0, 360.0].
Sourcepub fn wrap(degrees: f64) -> Result<Self>
pub fn wrap(degrees: f64) -> Result<Self>
Direction from any finite value, normalised into [0.0, 360.0).
§Errors
KernelError::NotFinite for NaN or infinity.
Sourcepub fn reciprocal(self) -> Self
pub fn reciprocal(self) -> Self
Reciprocal direction.
Sourcepub fn components(self, magnitude: f64) -> (f64, f64)
pub fn components(self, magnitude: f64) -> (f64, f64)
North and east components of a vector of magnitude in this direction,
in the magnitude’s unit.
The single place where velocity triangles (current triangle, relative motion, drift) resolve their sides.
Sourcepub fn signed_difference(self, other: Self) -> f64
pub fn signed_difference(self, other: Self) -> f64
Signed shortest angle from self to other, in [-180.0, 180.0);
positive clockwise.
Sourcepub fn angular_distance(self, other: Self) -> f64
pub fn angular_distance(self, other: Self) -> f64
Unsigned shortest angle between two directions, in [0.0, 180.0].
Trait Implementations§
impl<F: Copy + Frame> Copy for Direction<F>
Source§impl<F: Frame> From<CardinalPoint> for Direction<F>
impl<F: Frame> From<CardinalPoint> for Direction<F>
Source§fn from(point: CardinalPoint) -> Self
fn from(point: CardinalPoint) -> Self
The point as a direction in any frame; the point itself has no frame.