Struct micromath::Quaternion [−][src]
pub struct Quaternion(_, _, _, _);
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:
x | 1 | i | j | k |
---|---|---|---|---|
1 | 1 | i | j | k |
i | i | -1 | k | -j |
j | j | -k | -1 | i |
k | k | j | -i | -1 |
Implementations
impl Quaternion
[src]
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²
.
pub fn axis_angle<C>(v: Vector3d<C>, theta: C) -> Self where
C: Component + Into<f32>,
[src]
C: Component + Into<f32>,
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]
C: Component + Into<f32>,
vector
only.Rotate a 3D vector using this quaternion.
pub fn scale<S>(self, scalar: S) -> Self where
S: Into<f32>,
[src]
S: Into<f32>,
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]
impl Add<Quaternion> for Quaternion
[src]impl AddAssign<Quaternion> for Quaternion
[src]
impl AddAssign<Quaternion> for Quaternion
[src]fn add_assign(&mut self, rhs: Self)
[src]
impl Clone for Quaternion
[src]
impl Clone for Quaternion
[src]fn clone(&self) -> Quaternion
[src]
pub fn clone_from(&mut self, source: &Self)
1.0.0[src]
impl Copy for Quaternion
[src]
impl Copy for Quaternion
[src]impl Default for Quaternion
[src]
impl Default for Quaternion
[src]impl From<(f32, f32, f32, f32)> for Quaternion
[src]
impl From<(f32, f32, f32, f32)> for Quaternion
[src]fn from(q: (f32, f32, f32, f32)) -> Quaternion
[src]
impl<C> From<Vector3d<C>> for Quaternion where
C: Component + Into<f32>,
[src]
impl<C> From<Vector3d<C>> for Quaternion where
C: Component + Into<f32>,
[src]vector
only.fn from(v: Vector3d<C>) -> Quaternion
[src]
impl Mul<Quaternion> for Quaternion
[src]
impl Mul<Quaternion> for Quaternion
[src]impl<C> Mul<Vector3d<C>> for Quaternion where
C: Component + Into<f32>,
[src]
impl<C> Mul<Vector3d<C>> for Quaternion where
C: Component + Into<f32>,
[src]vector
only.impl Mul<f32> for Quaternion
[src]
impl Mul<f32> for Quaternion
[src]impl MulAssign<f32> for Quaternion
[src]
impl MulAssign<f32> for Quaternion
[src]fn mul_assign(&mut self, k: f32)
[src]
impl PartialEq<Quaternion> for Quaternion
[src]
impl PartialEq<Quaternion> for Quaternion
[src]fn eq(&self, other: &Quaternion) -> bool
[src]
fn ne(&self, other: &Quaternion) -> bool
[src]
impl StructuralPartialEq for Quaternion
[src]
impl StructuralPartialEq for Quaternion
[src]impl Sub<Quaternion> for Quaternion
[src]
impl Sub<Quaternion> for Quaternion
[src]impl SubAssign<Quaternion> for Quaternion
[src]
impl SubAssign<Quaternion> for Quaternion
[src]