Skip to main content

Rotor

Struct Rotor 

Source
pub struct Rotor<const D: usize> { /* private fields */ }
Expand description

A rotor — performs rotations in D dimensions.

Internally stores the rotation matrix. This is optimal for the hot path (applying rotations to many points) and avoids lossy rotor↔matrix round-trips. Construction uses geometric algebra (bivectors, plane-angle), but once built the matrix is the canonical representation.

Stack-allocated via SMatrix<f64, D, D>.

Implementations§

Source§

impl<const D: usize> Rotor<D>

Source

pub fn identity() -> Self

Identity rotor (no rotation).

Source

pub fn from_plane_angle(plane: &Bivector<D>, angle: f64) -> Self

Rotation by angle radians in the plane defined by plane bivector.

Positive angle rotates from the first axis toward the second axis of the plane (e.g., unit_plane(0,1) with positive angle rotates x→y).

Uses Rodrigues formula: M = I - sin(θ)*B̂ + (1-cos(θ))*B̂² (The sign on sin is negative because our bivector convention has B̂[i,j]=+1, B̂[j,i]=-1, producing clockwise rotation. The negation makes positive angles go counterclockwise: axis_i → axis_j.)

Source

pub fn from_vectors(from: &SVector<f64, D>, to: &SVector<f64, D>) -> Self

Rotation from unit vector from to unit vector to.

Source

pub fn from_matrix(mat: SMatrix<f64, D, D>) -> Self

Direct construction from a rotation matrix (must be orthogonal, det=+1).

Source

pub fn to_matrix(&self) -> &SMatrix<f64, D, D>

Get the rotation matrix.

Source

pub fn reverse(&self) -> Self

Reverse (inverse): R† = R^T for rotation matrices.

Source

pub fn compose(&self, other: &Self) -> Self

Compose: apply other first, then self.

Source

pub fn rotate_point(&self, point: &Point<D>) -> Point<D>

Rotate a point.

Source

pub fn rotate_vector(&self, v: &SVector<f64, D>) -> SVector<f64, D>

Rotate a vector.

Source

pub fn slerp(&self, t: f64) -> Self

Slerp: identity at t=0, this rotation at t=1.

Extracts the rotation angle and plane from the matrix, then builds a partial rotation.

Trait Implementations§

Source§

impl<const D: usize> Clone for Rotor<D>

Source§

fn clone(&self) -> Rotor<D>

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<const D: usize> Debug for Rotor<D>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<const D: usize> Default for Rotor<D>

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

§

impl<const D: usize> Freeze for Rotor<D>

§

impl<const D: usize> RefUnwindSafe for Rotor<D>

§

impl<const D: usize> Send for Rotor<D>

§

impl<const D: usize> Sync for Rotor<D>

§

impl<const D: usize> Unpin for Rotor<D>

§

impl<const D: usize> UnsafeUnpin for Rotor<D>

§

impl<const D: usize> UnwindSafe for Rotor<D>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<SS, SP> SupersetOf<SS> for SP
where SS: SubsetOf<SP>,

Source§

fn to_subset(&self) -> Option<SS>

The inverse inclusion map: attempts to construct self from the equivalent element of its superset. Read more
Source§

fn is_in_subset(&self) -> bool

Checks if self is actually part of its subset T (and can be converted to it).
Source§

fn to_subset_unchecked(&self) -> SS

Use with care! Same as self.to_subset but without any property checks. Always succeeds.
Source§

fn from_subset(element: &SS) -> SP

The inclusion map: converts self to the equivalent element of its superset.
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.