Skip to main content

Rotation3

Struct Rotation3 

Source
pub struct Rotation3 { /* private fields */ }
Expand description

A rotation in three dimensions, stored as a unit quaternion.

Implementations§

Source§

impl Rotation3

Source

pub fn identity() -> Self

Source

pub fn from_quaternion(q: Quaternion) -> Self

Wraps a quaternion, normalising it.

Source

pub fn from_axis_angle(axis: [f64; 3], angle: f64) -> Self

Source

pub fn from_matrix(m: &Matrix3) -> Self

From a rotation matrix; use nearest_rotation_matrix first if it may be noisy.

Source

pub fn from_euler(sequence: EulerSequence, angles: [f64; 3]) -> Self

Source

pub fn from_two_vectors(from: [f64; 3], to: [f64; 3]) -> Self

The shortest rotation taking direction from to direction to.

Source

pub fn quaternion(&self) -> Quaternion

Source

pub fn matrix(&self) -> Matrix3

Source

pub fn axis_angle(&self) -> ([f64; 3], f64)

Unit axis and angle in [0, π].

Source

pub fn to_euler(&self, sequence: EulerSequence) -> Option<[f64; 3]>

Source

pub fn inverse(&self) -> Self

Source

pub fn rotate(&self, v: [f64; 3]) -> [f64; 3]

Applies the rotation to a vector.

Source

pub fn rotate_about(&self, p: [f64; 3], pivot: [f64; 3]) -> [f64; 3]

Rotates a point about pivot instead of the origin.

Source

pub fn angle_to(&self, other: &Rotation3) -> f64

The angle of the rotation that takes self to other.

Source

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

Source

pub fn from_rotvec(v: [f64; 3]) -> Self

From a rotation vector (SciPy’s from_rotvec): the axis scaled by the angle in radians.

Source

pub fn as_rotvec(&self) -> [f64; 3]

The rotation vector (SciPy’s as_rotvec): axis times angle, the angle in [0, π].

Source

pub fn from_mrp(p: [f64; 3]) -> Self

From modified Rodrigues parameters p = n tan(θ/4) (SciPy’s from_mrp).

Source

pub fn as_mrp(&self) -> [f64; 3]

The modified Rodrigues parameters n tan(θ/4), θ ∈ [0, π] (SciPy’s as_mrp).

Source

pub fn from_uniform(u1: f64, u2: f64, u3: f64) -> Self

A rotation from three numbers uniform on [0, 1) (Shoemake’s method): with uniform inputs the rotations are uniformly distributed (Haar measure), as SciPy’s Rotation.random.

Source

pub fn random(n: usize, next: impl FnMut() -> f64) -> Vec<Rotation3>

n uniformly distributed random rotations, drawing uniforms on [0, 1) from next.

Trait Implementations§

Source§

impl Clone for Rotation3

Source§

fn clone(&self) -> Self

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 Copy for Rotation3

Source§

impl Debug for Rotation3

Source§

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

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

impl From<Quaternion> for Rotation3

Source§

fn from(q: Quaternion) -> Self

Converts to this type from the input type.
Source§

impl Mul for Rotation3

Source§

fn mul(self, o: Rotation3) -> Rotation3

a * b applies b first, then a.

Source§

type Output = Rotation3

The resulting type after applying the * operator.
Source§

impl PartialEq for Rotation3

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for Rotation3

Auto Trait Implementations§

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> MaybeSerialize for T
where T: ?Sized,

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 = !

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

fn try_from(value: U) -> Result<T, !>

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.