pub struct Radians(pub f32);Expand description
A type-safe wrapper for angular measurements in radians.
Range: Usually normalized to (-π, π] for flight dynamics.
Tuple Fields§
§0: f32Implementations§
Source§impl Radians
impl Radians
Sourcepub fn normalize(&self) -> Self
pub fn normalize(&self) -> Self
Normalizes the angle to the range (-π, π].
This is essential for preventing “the long way around” maneuvers and ensuring the PID controller receives the smallest possible error.
§Performance
This implementation uses a deterministic approach to ensure consistent execution time in real-time flight loops.
Sourcepub fn shortest_distance_to(&self, target: Radians) -> f32
pub fn shortest_distance_to(&self, target: Radians) -> f32
Calculates the shortest angular distance to a target.
Returns a value in the range (-π, π]. A positive result indicates a clockwise rotation, while a negative result indicates counter-clockwise.
§Example
Moving from 179° to -179° will return a distance of 2° (0.035 rad) instead of -358°.
Trait Implementations§
impl Copy for Radians
impl StructuralPartialEq for Radians
Auto Trait Implementations§
impl Freeze for Radians
impl RefUnwindSafe for Radians
impl Send for Radians
impl Sync for Radians
impl Unpin for Radians
impl UnsafeUnpin for Radians
impl UnwindSafe for Radians
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more