pub struct Quaternion<T, A: Alignment>(/* private fields */)
where
T: Scalar;Expand description
A quaternion representing an orientation.
Note: Quaternion is currently missing most of its functionality.
This quaternion is intended to be of unit length but may denormalize due to floating point “error creep” which can occur when successive quaternion operations are applied.
Quaternion is the generic form of:
Quaternion is generic over:
§Guarantees
Quaternion<T, A> is a transparent wrapper around Vector<4, T, A>, and
thus inherits its guarantees.
Implementations§
Source§impl<T, A: Alignment> Quaternion<T, A>where
T: Scalar,
impl<T, A: Alignment> Quaternion<T, A>where
T: Scalar,
Sourcepub const fn new(x: T, y: T, z: T, w: T) -> Self
pub const fn new(x: T, y: T, z: T, w: T) -> Self
Creates a rotation quaternion.
This is currently the only way to initialize a quaternion. In the future there will be mathamatical constructors that are recommended over this one.
§Unchecked
This function does not check if the input is normalized. It is up to the user to provide normalized input or to normalize the resulting quaternion.
Sourcepub const fn from_array(array: [T; 4]) -> Self
pub const fn from_array(array: [T; 4]) -> Self
Creates a rotation quaternion from an array.
§Unchecked
This function does not check if the input is normalized. It is up to the user to provide normalized input or to normalize the resulting quaternion.
Sourcepub const fn from_vec(vec: Vector<4, T, A>) -> Self
pub const fn from_vec(vec: Vector<4, T, A>) -> Self
Creates a rotation quaternion from a 4-dimensional vector.
§Unchecked
This function does not check if the input is normalized. It is up to the user to provide normalized input or to normalize the resulting quaternion.
Sourcepub const fn to_alignment<A2: Alignment>(self) -> Quaternion<T, A2>
pub const fn to_alignment<A2: Alignment>(self) -> Quaternion<T, A2>
Converts the quaternion to the specified alignment.
See Alignment for more information.
Sourcepub const fn align(self) -> Quaternion<T, Aligned>
pub const fn align(self) -> Quaternion<T, Aligned>
Sourcepub const fn unalign(self) -> Quaternion<T, Unaligned>
pub const fn unalign(self) -> Quaternion<T, Unaligned>
Sourcepub const fn as_array_ref(&self) -> &[T; 4]
pub const fn as_array_ref(&self) -> &[T; 4]
Returns a reference to the quaternion’s components.
Sourcepub const fn as_array_mut(&mut self) -> &mut [T; 4]
pub const fn as_array_mut(&mut self) -> &mut [T; 4]
Returns a mutable reference to the quaternion’s components.
Sourcepub const fn to_vec(self) -> Vector<4, T, A>
pub const fn to_vec(self) -> Vector<4, T, A>
Converts the quaternion to a 4-dimensional vector.
Sourcepub const fn as_vec_ref(&self) -> &Vector<4, T, A>
pub const fn as_vec_ref(&self) -> &Vector<4, T, A>
Returns a reference to the quaternion as a 4-dimensional vector.
Sourcepub const fn as_vec_mut(&mut self) -> &mut Vector<4, T, A>
pub const fn as_vec_mut(&mut self) -> &mut Vector<4, T, A>
Returns a mutable reference to the quaternion as a 4-dimensional vector.
Source§impl<T, A: Alignment> Quaternion<T, A>
impl<T, A: Alignment> Quaternion<T, A>
Source§impl<T, A: Alignment> Quaternion<T, A>
impl<T, A: Alignment> Quaternion<T, A>
Trait Implementations§
Source§impl<T, A: Alignment> Add for Quaternion<T, A>
impl<T, A: Alignment> Add for Quaternion<T, A>
Source§fn add(self, rhs: Self) -> Self::Output
fn add(self, rhs: Self) -> Self::Output
Adds two quaternions.
The sum is not guaranteed to be normalized.
Note that addition is not the same as combining the rotations represented by the two quaternions! That corresponds to multiplication (not implemented yet).
Source§type Output = Quaternion<T, A>
type Output = Quaternion<T, A>
+ operator.Source§impl<T, A: Alignment> AddAssign for Quaternion<T, A>
impl<T, A: Alignment> AddAssign for Quaternion<T, A>
Source§fn add_assign(&mut self, rhs: Self)
fn add_assign(&mut self, rhs: Self)
Adds the quaternion rhs to self.
The sum is not guaranteed to be normalized.
Note that addition is not the same as combining the rotations represented by the two quaternions! That corresponds to multiplication (not implemented yet).
Source§impl<T, A: Alignment> Debug for Quaternion<T, A>
impl<T, A: Alignment> Debug for Quaternion<T, A>
Source§impl<T, A: Alignment> Default for Quaternion<T, A>
impl<T, A: Alignment> Default for Quaternion<T, A>
Source§impl<T, A: Alignment> Display for Quaternion<T, A>
impl<T, A: Alignment> Display for Quaternion<T, A>
Source§impl<T, A: Alignment> Hash for Quaternion<T, A>
impl<T, A: Alignment> Hash for Quaternion<T, A>
Source§impl<T, A: Alignment> Mul<T> for Quaternion<T, A>
impl<T, A: Alignment> Mul<T> for Quaternion<T, A>
Source§impl<T, A: Alignment> MulAssign<T> for Quaternion<T, A>
impl<T, A: Alignment> MulAssign<T> for Quaternion<T, A>
Source§fn mul_assign(&mut self, rhs: T)
fn mul_assign(&mut self, rhs: T)
Multiplies the quaternion by a scalar value.
The product is not guaranteed to be normalized.
Source§impl<T, A: Alignment> Neg for Quaternion<T, A>
impl<T, A: Alignment> Neg for Quaternion<T, A>
Source§impl<T, A: Alignment> PartialEq for Quaternion<T, A>
impl<T, A: Alignment> PartialEq for Quaternion<T, A>
Source§impl<T, A: Alignment> Sub for Quaternion<T, A>
impl<T, A: Alignment> Sub for Quaternion<T, A>
Source§impl<T, A: Alignment> SubAssign for Quaternion<T, A>
impl<T, A: Alignment> SubAssign for Quaternion<T, A>
Source§fn sub_assign(&mut self, rhs: Self)
fn sub_assign(&mut self, rhs: Self)
Subtracts the quaternion rhs from self.
The difference is not guaranteed to be normalized.