Trait geo_nd::Quaternion[][src]

pub trait Quaternion<F, V3, V4>: Clone + Copy + Debug + Display + Default + AsRef<[F; 4]> + AsMut<[F; 4]> + AsRef<[F]> + AsMut<[F]> + Index<usize, Output = F> + IndexMut<usize> + Neg<Output = Self> + Add<Self, Output = Self> + Add<F, Output = Self> + AddAssign<Self> + AddAssign<F> + Sub<Self, Output = Self> + Sub<F, Output = Self> + SubAssign<Self> + SubAssign<F> + Mul<F, Output = Self> + MulAssign<F> + Div<F, Output = Self> + DivAssign<F> where
    V3: Vector<F, 3>,
    V4: Vector<F, 4>,
    F: Float
{
Show 18 methods fn from_array(data: [F; 4]) -> Self;
fn as_rijk(&self) -> (F, F, F, F);
fn of_rijk(r: F, i: F, j: F, k: F) -> Self;
fn unit() -> Self;
fn set_zero(&mut self);
fn mix(&self, other: &Self, t: F) -> Self;
fn dot(&self, other: &Self) -> F;
fn of_rotation3<M>(rotation: &M) -> Self
    where
        M: SqMatrix<V3, F, 3, 9>
;
fn set_rotation3<M>(&self, m: &mut M)
    where
        M: SqMatrix<V3, F, 3, 9>
;
fn set_rotation4<M>(&self, m: &mut M)
    where
        M: SqMatrix<V4, F, 4, 16>
; fn conjugate(&self) -> Self { ... }
fn of_axis_angle(axis: &V3, angle: F) -> Self { ... }
fn as_axis_angle(&self) -> (V3, F) { ... }
fn length_sq(&self) -> F { ... }
fn length(&self) -> F { ... }
fn distance_sq(&self, other: &Self) -> F { ... }
fn distance(&self, other: &Self) -> F { ... }
fn normalize(&mut self) { ... }
}
Expand description

The Quaternion trait describes a 4-dimensional vector of Float type.

Such Quaternions support basic arithmetic using addition and subtraction, and they provide quaternion multiplication and division.

They also support basic arithmetic to all components of the Quaternion for addition, subtraction, multiplication and division by a scalar Float value type that they are comprised of. Hence a q:Quaternion<F> may be scaled by a s:F using q * s.

The Quaternion can be indexed only by a usize; that is individual components of the vector can be accessed, but ranges may not.

Required methods

Create a quaternion from an array of Float

Break out into r, i, j, k

Create from r, i, j, k

Create a quaternion whose elements are all zero

Set the quaternion to be all zeros

Create a linear combination of this Quaternion and another using parameter t from zero to one

Return the dot product of two quaternions; basically used for length

Find the unit quaternion of a Matrix3 assuming it is purely a rotation

Set a Matrix3 to be the rotation matrix corresponding to the unit quaternion

Set a Matrix4 to be the rotation matrix corresponding to the unit quaternion

Provided methods

Create the conjugate of a quaternion

Return the square of the length of the quaternion

Return the length of the quaternion

Return the square of the distance between this quaternion and another

Return the distance between this quaternion and another

Normalize the quaternion; if its length is close to zero, then set it to be zero

Implementors