Struct micromath::Quaternion[][src]

pub struct Quaternion(_, _, _, _);
This is supported on crate feature quaternion only.

Quaternions are a number system that extends the complex numbers which can be used for efficiently computing spatial rotations.

They’re computed as the quotient of two directed lines in a three-dimensional space, or equivalently as the quotient of two vectors.

For given real numbers a, b, c, and d, they take the form:

a + bi + cj + dk

where i, j, and k are the fundamental quaternion units:

i² = j² = k² = i*j*k = -1

Quaternion multiplication is non-commutative:

x1ijk
11ijk
ii-1k-j
jj-k-1i
kkj-i-1

Implementations

impl Quaternion[src]

pub const IDENTITY: Self[src]

Identity quaternion.

pub const fn new(a: f32, b: f32, c: f32, d: f32) -> Self[src]

Create a new quaternion.

pub fn conj(self) -> Self[src]

Returns the conjugate of this quaternion.

pub fn dot(self, rhs: Self) -> f32[src]

Returns the dot product of this quaternion.

pub fn inv(self) -> Self[src]

Compute the inverse of this quaternion.

Panics if Quaternion::norm is zero.

pub fn magnitude(self) -> f32[src]

Compute the magnitude (a.k.a length) of this quaternion.

pub fn norm(self) -> f32[src]

Returns the norm of this quaternion, i.e. a²+b²+c²+d².

https://www.mathworks.com/help/aeroblks/quaternionnorm.html

pub fn axis_angle<C>(v: Vector3d<C>, theta: C) -> Self where
    C: Component + Into<f32>, 
[src]

This is supported on crate feature vector only.

Compute a quaternion for the given axis vector and angle.

pub fn rotate<C>(self, v: Vector3d<C>) -> F32x3 where
    C: Component + Into<f32>, 
[src]

This is supported on crate feature vector only.

Rotate a 3D vector using this quaternion.

pub fn scale<S>(self, scalar: S) -> Self where
    S: Into<f32>, 
[src]

Scale by a scalar.

pub fn to_array(&self) -> [f32; 4][src]

Convert this quaternion into an array.

Trait Implementations

impl Add<Quaternion> for Quaternion[src]

type Output = Self

The resulting type after applying the + operator.

impl AddAssign<Quaternion> for Quaternion[src]

impl Clone for Quaternion[src]

impl Copy for Quaternion[src]

impl Debug for Quaternion[src]

impl Default for Quaternion[src]

impl From<(f32, f32, f32, f32)> for Quaternion[src]

impl<C> From<Vector3d<C>> for Quaternion where
    C: Component + Into<f32>, 
[src]

This is supported on crate feature vector only.

impl Mul<Quaternion> for Quaternion[src]

type Output = Self

The resulting type after applying the * operator.

impl<C> Mul<Vector3d<C>> for Quaternion where
    C: Component + Into<f32>, 
[src]

This is supported on crate feature vector only.

type Output = F32x3

The resulting type after applying the * operator.

impl Mul<f32> for Quaternion[src]

type Output = Self

The resulting type after applying the * operator.

impl MulAssign<f32> for Quaternion[src]

impl PartialEq<Quaternion> for Quaternion[src]

impl StructuralPartialEq for Quaternion[src]

impl Sub<Quaternion> for Quaternion[src]

type Output = Self

The resulting type after applying the - operator.

impl SubAssign<Quaternion> for Quaternion[src]

Auto Trait Implementations

impl Send for Quaternion

impl Sync for Quaternion

impl Unpin for Quaternion

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.