pub struct SO2State {
pub value: f64,
}Expand description
A state representing a 2D rotation, an element of the Special Orthogonal group SO(2).
The angle is stored in radians and is canonically represented in the range [-PI, PI).
Fields§
§value: f64Angle of rotation in radians.
Implementations§
Source§impl SO2State
impl SO2State
Sourcepub fn new(val: f64) -> Self
pub fn new(val: f64) -> Self
Creates a new SO2State, normalising the input angle to range [-PI, PI).
This constructor ensures that no matter the input value, resulting state’s value will be a
valid, equivalent angle within [-PI, PI).
§Examples
use std::f64::consts::PI;
use oxmpl::base::state::SO2State;
let state1 = SO2State::new(3.0 * PI / 2.0);
assert!((state1.value - (-PI / 2.0)).abs() < 1e-9);
let state2 = SO2State::new(5.0 * PI);
assert!((state2.value + PI).abs() < 1e-9);Sourcepub fn normalise(&mut self) -> Self
pub fn normalise(&mut self) -> Self
Normalises the state’s angle in-place to range [-PI, PI).
Method modifies the current state.
§Examples
use std::f64::consts::PI;
use oxmpl::base::state::SO2State;
let mut state = SO2State { value: 3.0 * PI / 2.0 }; // Equivalent to -PI/2
state = state.normalise();
assert!((state.value + PI / 2.0).abs() < 1e-9);Trait Implementations§
impl StructuralPartialEq for SO2State
Auto Trait Implementations§
impl Freeze for SO2State
impl RefUnwindSafe for SO2State
impl Send for SO2State
impl Sync for SO2State
impl Unpin for SO2State
impl UnsafeUnpin for SO2State
impl UnwindSafe for SO2State
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