Struct nalgebra::geometry::Quaternion
source · [−]#[repr(C)]pub struct Quaternion<T> {
pub coords: Vector4<T>,
}
Expand description
A quaternion. See the type alias UnitQuaternion = Unit<Quaternion>
for a quaternion
that may be used as a rotation.
Fields
coords: Vector4<T>
This quaternion as a 4D vector of coordinates in the [ x, y, z, w ]
storage order.
Implementations
sourceimpl<T: SimdRealField> Quaternion<T> where
T::Element: SimdRealField,
impl<T: SimdRealField> Quaternion<T> where
T::Element: SimdRealField,
sourcepub fn into_owned(self) -> Self
👎 Deprecated: This method is a no-op and will be removed in a future release.
pub fn into_owned(self) -> Self
This method is a no-op and will be removed in a future release.
Moves this unit quaternion into one that owns its data.
sourcepub fn clone_owned(&self) -> Self
👎 Deprecated: This method is a no-op and will be removed in a future release.
pub fn clone_owned(&self) -> Self
This method is a no-op and will be removed in a future release.
Clones this unit quaternion into one that owns its data.
sourcepub fn normalize(&self) -> Self
pub fn normalize(&self) -> Self
Normalizes this quaternion.
Example
let q = Quaternion::new(1.0, 2.0, 3.0, 4.0);
let q_normalized = q.normalize();
relative_eq!(q_normalized.norm(), 1.0);
sourcepub fn conjugate(&self) -> Self
pub fn conjugate(&self) -> Self
The conjugate of this quaternion.
Example
let q = Quaternion::new(1.0, 2.0, 3.0, 4.0);
let conj = q.conjugate();
assert!(conj.i == -2.0 && conj.j == -3.0 && conj.k == -4.0 && conj.w == 1.0);
sourcepub fn lerp(&self, other: &Self, t: T) -> Self
pub fn lerp(&self, other: &Self, t: T) -> Self
Linear interpolation between two quaternion.
Computes self * (1 - t) + other * t
.
Example
let q1 = Quaternion::new(1.0, 2.0, 3.0, 4.0);
let q2 = Quaternion::new(10.0, 20.0, 30.0, 40.0);
assert_eq!(q1.lerp(&q2, 0.1), Quaternion::new(1.9, 3.8, 5.7, 7.6));
sourcepub fn vector(
&self
) -> MatrixSlice<'_, T, U3, U1, RStride<T, U4, U1>, CStride<T, U4, U1>>
pub fn vector(
&self
) -> MatrixSlice<'_, T, U3, U1, RStride<T, U4, U1>, CStride<T, U4, U1>>
The vector part (i, j, k)
of this quaternion.
Example
let q = Quaternion::new(1.0, 2.0, 3.0, 4.0);
assert_eq!(q.vector()[0], 2.0);
assert_eq!(q.vector()[1], 3.0);
assert_eq!(q.vector()[2], 4.0);
sourcepub fn scalar(&self) -> T
pub fn scalar(&self) -> T
The scalar part w
of this quaternion.
Example
let q = Quaternion::new(1.0, 2.0, 3.0, 4.0);
assert_eq!(q.scalar(), 1.0);
sourcepub fn as_vector(&self) -> &Vector4<T>
pub fn as_vector(&self) -> &Vector4<T>
Reinterprets this quaternion as a 4D vector.
Example
let q = Quaternion::new(1.0, 2.0, 3.0, 4.0);
// Recall that the quaternion is stored internally as (i, j, k, w)
// while the crate::new constructor takes the arguments as (w, i, j, k).
assert_eq!(*q.as_vector(), Vector4::new(2.0, 3.0, 4.0, 1.0));
sourcepub fn norm(&self) -> T
pub fn norm(&self) -> T
The norm of this quaternion.
Example
let q = Quaternion::new(1.0, 2.0, 3.0, 4.0);
assert_relative_eq!(q.norm(), 5.47722557, epsilon = 1.0e-6);
sourcepub fn magnitude(&self) -> T
pub fn magnitude(&self) -> T
A synonym for the norm of this quaternion.
Aka the length.
This is the same as .norm()
Example
let q = Quaternion::new(1.0, 2.0, 3.0, 4.0);
assert_relative_eq!(q.magnitude(), 5.47722557, epsilon = 1.0e-6);
sourcepub fn norm_squared(&self) -> T
pub fn norm_squared(&self) -> T
The squared norm of this quaternion.
Example
let q = Quaternion::new(1.0, 2.0, 3.0, 4.0);
assert_eq!(q.magnitude_squared(), 30.0);
sourcepub fn magnitude_squared(&self) -> T
pub fn magnitude_squared(&self) -> T
A synonym for the squared norm of this quaternion.
Aka the squared length.
This is the same as .norm_squared()
Example
let q = Quaternion::new(1.0, 2.0, 3.0, 4.0);
assert_eq!(q.magnitude_squared(), 30.0);
sourceimpl<T: SimdRealField> Quaternion<T> where
T::Element: SimdRealField,
impl<T: SimdRealField> Quaternion<T> where
T::Element: SimdRealField,
sourcepub fn try_inverse(&self) -> Option<Self> where
T: RealField,
pub fn try_inverse(&self) -> Option<Self> where
T: RealField,
Inverts this quaternion if it is not zero.
This method also does not works with SIMD components (see simd_try_inverse
instead).
Example
let q = Quaternion::new(1.0, 2.0, 3.0, 4.0);
let inv_q = q.try_inverse();
assert!(inv_q.is_some());
assert_relative_eq!(inv_q.unwrap() * q, Quaternion::identity());
//Non-invertible case
let q = Quaternion::new(0.0, 0.0, 0.0, 0.0);
let inv_q = q.try_inverse();
assert!(inv_q.is_none());
sourcepub fn simd_try_inverse(&self) -> SimdOption<Self>
pub fn simd_try_inverse(&self) -> SimdOption<Self>
Attempt to inverse this quaternion.
This method also works with SIMD components.
sourcepub fn inner(&self, other: &Self) -> Self
pub fn inner(&self, other: &Self) -> Self
Calculates the inner product (also known as the dot product). See “Foundations of Game Engine Development, Volume 1: Mathematics” by Lengyel Formula 4.89.
Example
let a = Quaternion::new(0.0, 2.0, 3.0, 4.0);
let b = Quaternion::new(0.0, 5.0, 2.0, 1.0);
let expected = Quaternion::new(-20.0, 0.0, 0.0, 0.0);
let result = a.inner(&b);
assert_relative_eq!(expected, result, epsilon = 1.0e-5);
sourcepub fn outer(&self, other: &Self) -> Self
pub fn outer(&self, other: &Self) -> Self
Calculates the outer product (also known as the wedge product). See “Foundations of Game Engine Development, Volume 1: Mathematics” by Lengyel Formula 4.89.
Example
let a = Quaternion::new(0.0, 2.0, 3.0, 4.0);
let b = Quaternion::new(0.0, 5.0, 2.0, 1.0);
let expected = Quaternion::new(0.0, -5.0, 18.0, -11.0);
let result = a.outer(&b);
assert_relative_eq!(expected, result, epsilon = 1.0e-5);
sourcepub fn project(&self, other: &Self) -> Option<Self> where
T: RealField,
pub fn project(&self, other: &Self) -> Option<Self> where
T: RealField,
Calculates the projection of self
onto other
(also known as the parallel).
See “Foundations of Game Engine Development, Volume 1: Mathematics” by Lengyel
Formula 4.94.
Example
let a = Quaternion::new(0.0, 2.0, 3.0, 4.0);
let b = Quaternion::new(0.0, 5.0, 2.0, 1.0);
let expected = Quaternion::new(0.0, 3.333333333333333, 1.3333333333333333, 0.6666666666666666);
let result = a.project(&b).unwrap();
assert_relative_eq!(expected, result, epsilon = 1.0e-5);
sourcepub fn reject(&self, other: &Self) -> Option<Self> where
T: RealField,
pub fn reject(&self, other: &Self) -> Option<Self> where
T: RealField,
Calculates the rejection of self
from other
(also known as the perpendicular).
See “Foundations of Game Engine Development, Volume 1: Mathematics” by Lengyel
Formula 4.94.
Example
let a = Quaternion::new(0.0, 2.0, 3.0, 4.0);
let b = Quaternion::new(0.0, 5.0, 2.0, 1.0);
let expected = Quaternion::new(0.0, -1.3333333333333333, 1.6666666666666665, 3.3333333333333335);
let result = a.reject(&b).unwrap();
assert_relative_eq!(expected, result, epsilon = 1.0e-5);
sourcepub fn polar_decomposition(&self) -> (T, T, Option<Unit<Vector3<T>>>) where
T: RealField,
pub fn polar_decomposition(&self) -> (T, T, Option<Unit<Vector3<T>>>) where
T: RealField,
The polar decomposition of this quaternion.
Returns, from left to right: the quaternion norm, the half rotation angle, the rotation
axis. If the rotation angle is zero, the rotation axis is set to None
.
Example
let q = Quaternion::new(0.0, 5.0, 0.0, 0.0);
let (norm, half_ang, axis) = q.polar_decomposition();
assert_eq!(norm, 5.0);
assert_eq!(half_ang, f32::consts::FRAC_PI_2);
assert_eq!(axis, Some(Vector3::x_axis()));
sourcepub fn ln(&self) -> Self
pub fn ln(&self) -> Self
Compute the natural logarithm of a quaternion.
Example
let q = Quaternion::new(2.0, 5.0, 0.0, 0.0);
assert_relative_eq!(q.ln(), Quaternion::new(1.683647, 1.190289, 0.0, 0.0), epsilon = 1.0e-6)
sourcepub fn exp(&self) -> Self
pub fn exp(&self) -> Self
Compute the exponential of a quaternion.
Example
let q = Quaternion::new(1.683647, 1.190289, 0.0, 0.0);
assert_relative_eq!(q.exp(), Quaternion::new(2.0, 5.0, 0.0, 0.0), epsilon = 1.0e-5)
sourcepub fn exp_eps(&self, eps: T) -> Self
pub fn exp_eps(&self, eps: T) -> Self
Compute the exponential of a quaternion. Returns the identity if the vector part of this quaternion
has a norm smaller than eps
.
Example
let q = Quaternion::new(1.683647, 1.190289, 0.0, 0.0);
assert_relative_eq!(q.exp_eps(1.0e-6), Quaternion::new(2.0, 5.0, 0.0, 0.0), epsilon = 1.0e-5);
// Singular case.
let q = Quaternion::new(0.0000001, 0.0, 0.0, 0.0);
assert_eq!(q.exp_eps(1.0e-6), Quaternion::identity());
sourcepub fn powf(&self, n: T) -> Self
pub fn powf(&self, n: T) -> Self
Raise the quaternion to a given floating power.
Example
let q = Quaternion::new(1.0, 2.0, 3.0, 4.0);
assert_relative_eq!(q.powf(1.5), Quaternion::new( -6.2576659, 4.1549037, 6.2323556, 8.3098075), epsilon = 1.0e-6);
sourcepub fn as_vector_mut(&mut self) -> &mut Vector4<T>
pub fn as_vector_mut(&mut self) -> &mut Vector4<T>
Transforms this quaternion into its 4D vector form (Vector part, Scalar part).
Example
let mut q = Quaternion::identity();
*q.as_vector_mut() = Vector4::new(1.0, 2.0, 3.0, 4.0);
assert!(q.i == 1.0 && q.j == 2.0 && q.k == 3.0 && q.w == 4.0);
sourcepub fn vector_mut(
&mut self
) -> MatrixSliceMut<'_, T, U3, U1, RStride<T, U4, U1>, CStride<T, U4, U1>>
pub fn vector_mut(
&mut self
) -> MatrixSliceMut<'_, T, U3, U1, RStride<T, U4, U1>, CStride<T, U4, U1>>
The mutable vector part (i, j, k)
of this quaternion.
Example
let mut q = Quaternion::identity();
{
let mut v = q.vector_mut();
v[0] = 2.0;
v[1] = 3.0;
v[2] = 4.0;
}
assert!(q.i == 2.0 && q.j == 3.0 && q.k == 4.0 && q.w == 1.0);
sourcepub fn conjugate_mut(&mut self)
pub fn conjugate_mut(&mut self)
Replaces this quaternion by its conjugate.
Example
let mut q = Quaternion::new(1.0, 2.0, 3.0, 4.0);
q.conjugate_mut();
assert!(q.i == -2.0 && q.j == -3.0 && q.k == -4.0 && q.w == 1.0);
sourcepub fn try_inverse_mut(&mut self) -> T::SimdBool
pub fn try_inverse_mut(&mut self) -> T::SimdBool
Inverts this quaternion in-place if it is not zero.
Example
let mut q = Quaternion::new(1.0f32, 2.0, 3.0, 4.0);
assert!(q.try_inverse_mut());
assert_relative_eq!(q * Quaternion::new(1.0, 2.0, 3.0, 4.0), Quaternion::identity());
//Non-invertible case
let mut q = Quaternion::new(0.0f32, 0.0, 0.0, 0.0);
assert!(!q.try_inverse_mut());
sourcepub fn normalize_mut(&mut self) -> T
pub fn normalize_mut(&mut self) -> T
Normalizes this quaternion.
Example
let mut q = Quaternion::new(1.0, 2.0, 3.0, 4.0);
q.normalize_mut();
assert_relative_eq!(q.norm(), 1.0);
sourcepub fn is_pure(&self) -> bool
pub fn is_pure(&self) -> bool
Check if the quaternion is pure.
A quaternion is pure if it has no real part (self.w == 0.0
).
sourcepub fn left_div(&self, other: &Self) -> Option<Self> where
T: RealField,
pub fn left_div(&self, other: &Self) -> Option<Self> where
T: RealField,
Left quaternionic division.
Calculates B-1 * A where A = self, B = other.
sourcepub fn right_div(&self, other: &Self) -> Option<Self> where
T: RealField,
pub fn right_div(&self, other: &Self) -> Option<Self> where
T: RealField,
Right quaternionic division.
Calculates A * B-1 where A = self, B = other.
Example
let a = Quaternion::new(0.0, 1.0, 2.0, 3.0);
let b = Quaternion::new(0.0, 5.0, 2.0, 1.0);
let result = a.right_div(&b).unwrap();
let expected = Quaternion::new(0.4, 0.13333333333333336, -0.4666666666666667, 0.26666666666666666);
assert_relative_eq!(expected, result, epsilon = 1.0e-7);
sourcepub fn cos(&self) -> Self
pub fn cos(&self) -> Self
Calculates the quaternionic cosinus.
Example
let input = Quaternion::new(1.0, 2.0, 3.0, 4.0);
let expected = Quaternion::new(58.93364616794395, -34.086183690465596, -51.1292755356984, -68.17236738093119);
let result = input.cos();
assert_relative_eq!(expected, result, epsilon = 1.0e-7);
sourcepub fn acos(&self) -> Self
pub fn acos(&self) -> Self
Calculates the quaternionic arccosinus.
Example
let input = Quaternion::new(1.0, 2.0, 3.0, 4.0);
let result = input.cos().acos();
assert_relative_eq!(input, result, epsilon = 1.0e-7);
sourcepub fn sin(&self) -> Self
pub fn sin(&self) -> Self
Calculates the quaternionic sinus.
Example
let input = Quaternion::new(1.0, 2.0, 3.0, 4.0);
let expected = Quaternion::new(91.78371578403467, 21.886486853029176, 32.82973027954377, 43.77297370605835);
let result = input.sin();
assert_relative_eq!(expected, result, epsilon = 1.0e-7);
sourcepub fn asin(&self) -> Self
pub fn asin(&self) -> Self
Calculates the quaternionic arcsinus.
Example
let input = Quaternion::new(1.0, 2.0, 3.0, 4.0);
let result = input.sin().asin();
assert_relative_eq!(input, result, epsilon = 1.0e-7);
sourcepub fn tan(&self) -> Self where
T: RealField,
pub fn tan(&self) -> Self where
T: RealField,
Calculates the quaternionic tangent.
Example
let input = Quaternion::new(1.0, 2.0, 3.0, 4.0);
let expected = Quaternion::new(0.00003821631725009489, 0.3713971716439371, 0.5570957574659058, 0.7427943432878743);
let result = input.tan();
assert_relative_eq!(expected, result, epsilon = 1.0e-7);
sourcepub fn atan(&self) -> Self where
T: RealField,
pub fn atan(&self) -> Self where
T: RealField,
Calculates the quaternionic arctangent.
Example
let input = Quaternion::new(1.0, 2.0, 3.0, 4.0);
let result = input.tan().atan();
assert_relative_eq!(input, result, epsilon = 1.0e-7);
sourcepub fn sinh(&self) -> Self
pub fn sinh(&self) -> Self
Calculates the hyperbolic quaternionic sinus.
Example
let input = Quaternion::new(1.0, 2.0, 3.0, 4.0);
let expected = Quaternion::new(0.7323376060463428, -0.4482074499805421, -0.6723111749708133, -0.8964148999610843);
let result = input.sinh();
assert_relative_eq!(expected, result, epsilon = 1.0e-7);
sourcepub fn asinh(&self) -> Self
pub fn asinh(&self) -> Self
Calculates the hyperbolic quaternionic arcsinus.
Example
let input = Quaternion::new(1.0, 2.0, 3.0, 4.0);
let expected = Quaternion::new(2.385889902585242, 0.514052600662788, 0.7710789009941821, 1.028105201325576);
let result = input.asinh();
assert_relative_eq!(expected, result, epsilon = 1.0e-7);
sourcepub fn cosh(&self) -> Self
pub fn cosh(&self) -> Self
Calculates the hyperbolic quaternionic cosinus.
Example
let input = Quaternion::new(1.0, 2.0, 3.0, 4.0);
let expected = Quaternion::new(0.9615851176369566, -0.3413521745610167, -0.5120282618415251, -0.6827043491220334);
let result = input.cosh();
assert_relative_eq!(expected, result, epsilon = 1.0e-7);
sourcepub fn acosh(&self) -> Self
pub fn acosh(&self) -> Self
Calculates the hyperbolic quaternionic arccosinus.
Example
let input = Quaternion::new(1.0, 2.0, 3.0, 4.0);
let expected = Quaternion::new(2.4014472020074007, 0.5162761016176176, 0.7744141524264264, 1.0325522032352352);
let result = input.acosh();
assert_relative_eq!(expected, result, epsilon = 1.0e-7);
sourcepub fn tanh(&self) -> Self where
T: RealField,
pub fn tanh(&self) -> Self where
T: RealField,
Calculates the hyperbolic quaternionic tangent.
Example
let input = Quaternion::new(1.0, 2.0, 3.0, 4.0);
let expected = Quaternion::new(1.0248695360556623, -0.10229568178876419, -0.1534435226831464, -0.20459136357752844);
let result = input.tanh();
assert_relative_eq!(expected, result, epsilon = 1.0e-7);
sourcepub fn atanh(&self) -> Self
pub fn atanh(&self) -> Self
Calculates the hyperbolic quaternionic arctangent.
Example
let input = Quaternion::new(1.0, 2.0, 3.0, 4.0);
let expected = Quaternion::new(0.03230293287000163, 0.5173453683196951, 0.7760180524795426, 1.0346907366393903);
let result = input.atanh();
assert_relative_eq!(expected, result, epsilon = 1.0e-7);
sourceimpl<T> Quaternion<T>
impl<T> Quaternion<T>
sourcepub const fn from_vector(vector: Vector4<T>) -> Self
pub const fn from_vector(vector: Vector4<T>) -> Self
Creates a quaternion from a 4D vector. The quaternion scalar part corresponds to the w
vector component.
sourcepub const fn new(w: T, i: T, j: T, k: T) -> Self
pub const fn new(w: T, i: T, j: T, k: T) -> Self
Creates a new quaternion from its individual components. Note that the arguments order does not follow the storage order.
The storage order is [ i, j, k, w ]
while the arguments for this functions are in the
order (w, i, j, k)
.
Example
let q = Quaternion::new(1.0, 2.0, 3.0, 4.0);
assert!(q.i == 2.0 && q.j == 3.0 && q.k == 4.0 && q.w == 1.0);
assert_eq!(*q.as_vector(), Vector4::new(2.0, 3.0, 4.0, 1.0));
sourcepub fn cast<To: Scalar>(self) -> Quaternion<To> where
T: Scalar,
To: SupersetOf<T>,
pub fn cast<To: Scalar>(self) -> Quaternion<To> where
T: Scalar,
To: SupersetOf<T>,
Cast the components of self
to another type.
Example
let q = Quaternion::new(1.0f64, 2.0, 3.0, 4.0);
let q2 = q.cast::<f32>();
assert_eq!(q2, Quaternion::new(1.0f32, 2.0, 3.0, 4.0));
sourceimpl<T: SimdRealField> Quaternion<T>
impl<T: SimdRealField> Quaternion<T>
sourcepub fn from_parts<SB>(scalar: T, vector: Vector<T, U3, SB>) -> Self where
SB: Storage<T, U3>,
pub fn from_parts<SB>(scalar: T, vector: Vector<T, U3, SB>) -> Self where
SB: Storage<T, U3>,
Creates a new quaternion from its scalar and vector parts. Note that the arguments order does not follow the storage order.
The storage order is [ vector, scalar ].
Example
let w = 1.0;
let ijk = Vector3::new(2.0, 3.0, 4.0);
let q = Quaternion::from_parts(w, ijk);
assert!(q.i == 2.0 && q.j == 3.0 && q.k == 4.0 && q.w == 1.0);
assert_eq!(*q.as_vector(), Vector4::new(2.0, 3.0, 4.0, 1.0));
sourceimpl<T: SimdRealField> Quaternion<T> where
T::Element: SimdRealField,
impl<T: SimdRealField> Quaternion<T> where
T::Element: SimdRealField,
Trait Implementations
sourceimpl<T: RealField + AbsDiffEq<Epsilon = T>> AbsDiffEq<Quaternion<T>> for Quaternion<T>
impl<T: RealField + AbsDiffEq<Epsilon = T>> AbsDiffEq<Quaternion<T>> for Quaternion<T>
type Epsilon = T
type Epsilon = T
Used for specifying relative comparisons.
sourcefn default_epsilon() -> Self::Epsilon
fn default_epsilon() -> Self::Epsilon
The default tolerance to use when testing values that are close together. Read more
sourcefn abs_diff_eq(&self, other: &Self, epsilon: Self::Epsilon) -> bool
fn abs_diff_eq(&self, other: &Self, epsilon: Self::Epsilon) -> bool
A test for equality that uses the absolute difference to compute the approximate equality of two numbers. Read more
sourcefn abs_diff_ne(&self, other: &Rhs, epsilon: Self::Epsilon) -> bool
fn abs_diff_ne(&self, other: &Rhs, epsilon: Self::Epsilon) -> bool
The inverse of AbsDiffEq::abs_diff_eq
.
sourceimpl<'a, 'b, T: SimdRealField> Add<&'b Quaternion<T>> for &'a Quaternion<T> where
T::Element: SimdRealField,
impl<'a, 'b, T: SimdRealField> Add<&'b Quaternion<T>> for &'a Quaternion<T> where
T::Element: SimdRealField,
type Output = Quaternion<T>
type Output = Quaternion<T>
The resulting type after applying the +
operator.
sourcefn add(self, rhs: &'b Quaternion<T>) -> Self::Output
fn add(self, rhs: &'b Quaternion<T>) -> Self::Output
Performs the +
operation. Read more
sourceimpl<'b, T: SimdRealField> Add<&'b Quaternion<T>> for Quaternion<T> where
T::Element: SimdRealField,
impl<'b, T: SimdRealField> Add<&'b Quaternion<T>> for Quaternion<T> where
T::Element: SimdRealField,
type Output = Quaternion<T>
type Output = Quaternion<T>
The resulting type after applying the +
operator.
sourcefn add(self, rhs: &'b Quaternion<T>) -> Self::Output
fn add(self, rhs: &'b Quaternion<T>) -> Self::Output
Performs the +
operation. Read more
sourceimpl<'a, T: SimdRealField> Add<Quaternion<T>> for &'a Quaternion<T> where
T::Element: SimdRealField,
impl<'a, T: SimdRealField> Add<Quaternion<T>> for &'a Quaternion<T> where
T::Element: SimdRealField,
type Output = Quaternion<T>
type Output = Quaternion<T>
The resulting type after applying the +
operator.
sourcefn add(self, rhs: Quaternion<T>) -> Self::Output
fn add(self, rhs: Quaternion<T>) -> Self::Output
Performs the +
operation. Read more
sourceimpl<T: SimdRealField> Add<Quaternion<T>> for Quaternion<T> where
T::Element: SimdRealField,
impl<T: SimdRealField> Add<Quaternion<T>> for Quaternion<T> where
T::Element: SimdRealField,
type Output = Quaternion<T>
type Output = Quaternion<T>
The resulting type after applying the +
operator.
sourcefn add(self, rhs: Quaternion<T>) -> Self::Output
fn add(self, rhs: Quaternion<T>) -> Self::Output
Performs the +
operation. Read more
sourceimpl<'b, T: SimdRealField> AddAssign<&'b Quaternion<T>> for Quaternion<T> where
T::Element: SimdRealField,
impl<'b, T: SimdRealField> AddAssign<&'b Quaternion<T>> for Quaternion<T> where
T::Element: SimdRealField,
sourcefn add_assign(&mut self, rhs: &'b Quaternion<T>)
fn add_assign(&mut self, rhs: &'b Quaternion<T>)
Performs the +=
operation. Read more
sourceimpl<T: SimdRealField> AddAssign<Quaternion<T>> for Quaternion<T> where
T::Element: SimdRealField,
impl<T: SimdRealField> AddAssign<Quaternion<T>> for Quaternion<T> where
T::Element: SimdRealField,
sourcefn add_assign(&mut self, rhs: Quaternion<T>)
fn add_assign(&mut self, rhs: Quaternion<T>)
Performs the +=
operation. Read more
sourceimpl<T: Clone> Clone for Quaternion<T>
impl<T: Clone> Clone for Quaternion<T>
sourcefn clone(&self) -> Quaternion<T>
fn clone(&self) -> Quaternion<T>
Returns a copy of the value. Read more
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
sourceimpl<T: Debug> Debug for Quaternion<T>
impl<T: Debug> Debug for Quaternion<T>
sourceimpl<T: Scalar + Zero> Default for Quaternion<T>
impl<T: Scalar + Zero> Default for Quaternion<T>
sourceimpl<T: Scalar + SimdValue> Deref for Quaternion<T>
impl<T: Scalar + SimdValue> Deref for Quaternion<T>
sourceimpl<T: Scalar + SimdValue> DerefMut for Quaternion<T>
impl<T: Scalar + SimdValue> DerefMut for Quaternion<T>
sourceimpl<T: RealField + Display> Display for Quaternion<T>
impl<T: RealField + Display> Display for Quaternion<T>
sourceimpl<T: SimdRealField> Distribution<Quaternion<T>> for Standard where
Standard: Distribution<T>,
impl<T: SimdRealField> Distribution<Quaternion<T>> for Standard where
Standard: Distribution<T>,
sourcefn sample<'a, R: Rng + ?Sized>(&self, rng: &'a mut R) -> Quaternion<T>
fn sample<'a, R: Rng + ?Sized>(&self, rng: &'a mut R) -> Quaternion<T>
Generate a random value of T
, using rng
as the source of randomness.
sourcefn sample_iter<R>(self, rng: R) -> DistIter<Self, R, T> where
R: Rng,
fn sample_iter<R>(self, rng: R) -> DistIter<Self, R, T> where
R: Rng,
Create an iterator that generates random values of T
, using rng
as
the source of randomness. Read more
sourceimpl<T: SimdRealField> Div<T> for Quaternion<T> where
T::Element: SimdRealField,
impl<T: SimdRealField> Div<T> for Quaternion<T> where
T::Element: SimdRealField,
sourceimpl<'a, T: SimdRealField> Div<T> for &'a Quaternion<T> where
T::Element: SimdRealField,
impl<'a, T: SimdRealField> Div<T> for &'a Quaternion<T> where
T::Element: SimdRealField,
sourceimpl<T: SimdRealField> DivAssign<T> for Quaternion<T> where
T::Element: SimdRealField,
impl<T: SimdRealField> DivAssign<T> for Quaternion<T> where
T::Element: SimdRealField,
sourcefn div_assign(&mut self, n: T)
fn div_assign(&mut self, n: T)
Performs the /=
operation. Read more
sourceimpl<T: Scalar + PrimitiveSimdValue> From<[Quaternion<<T as SimdValue>::Element>; 16]> for Quaternion<T> where
T: From<[<T as SimdValue>::Element; 16]>,
T::Element: Scalar + Copy,
impl<T: Scalar + PrimitiveSimdValue> From<[Quaternion<<T as SimdValue>::Element>; 16]> for Quaternion<T> where
T: From<[<T as SimdValue>::Element; 16]>,
T::Element: Scalar + Copy,
sourceimpl<T: Scalar + PrimitiveSimdValue> From<[Quaternion<<T as SimdValue>::Element>; 2]> for Quaternion<T> where
T: From<[<T as SimdValue>::Element; 2]>,
T::Element: Scalar + Copy,
impl<T: Scalar + PrimitiveSimdValue> From<[Quaternion<<T as SimdValue>::Element>; 2]> for Quaternion<T> where
T: From<[<T as SimdValue>::Element; 2]>,
T::Element: Scalar + Copy,
sourceimpl<T: Scalar + PrimitiveSimdValue> From<[Quaternion<<T as SimdValue>::Element>; 4]> for Quaternion<T> where
T: From<[<T as SimdValue>::Element; 4]>,
T::Element: Scalar + Copy,
impl<T: Scalar + PrimitiveSimdValue> From<[Quaternion<<T as SimdValue>::Element>; 4]> for Quaternion<T> where
T: From<[<T as SimdValue>::Element; 4]>,
T::Element: Scalar + Copy,
sourceimpl<T: Scalar + PrimitiveSimdValue> From<[Quaternion<<T as SimdValue>::Element>; 8]> for Quaternion<T> where
T: From<[<T as SimdValue>::Element; 8]>,
T::Element: Scalar + Copy,
impl<T: Scalar + PrimitiveSimdValue> From<[Quaternion<<T as SimdValue>::Element>; 8]> for Quaternion<T> where
T: From<[<T as SimdValue>::Element; 8]>,
T::Element: Scalar + Copy,
sourceimpl<T: Scalar> From<Matrix<T, Const<{ typenum::$D::USIZE }>, Const<1_usize>, ArrayStorage<T, 4_usize, 1_usize>>> for Quaternion<T>
impl<T: Scalar> From<Matrix<T, Const<{ typenum::$D::USIZE }>, Const<1_usize>, ArrayStorage<T, 4_usize, 1_usize>>> for Quaternion<T>
sourceimpl<T: Scalar + Hash> Hash for Quaternion<T>
impl<T: Scalar + Hash> Hash for Quaternion<T>
sourceimpl<T: Scalar> Index<usize> for Quaternion<T>
impl<T: Scalar> Index<usize> for Quaternion<T>
sourceimpl<T: Scalar> IndexMut<usize> for Quaternion<T>
impl<T: Scalar> IndexMut<usize> for Quaternion<T>
sourceimpl<'a, 'b, T: SimdRealField> Mul<&'b Quaternion<T>> for &'a Quaternion<T> where
T::Element: SimdRealField,
impl<'a, 'b, T: SimdRealField> Mul<&'b Quaternion<T>> for &'a Quaternion<T> where
T::Element: SimdRealField,
type Output = Quaternion<T>
type Output = Quaternion<T>
The resulting type after applying the *
operator.
sourcefn mul(self, rhs: &'b Quaternion<T>) -> Self::Output
fn mul(self, rhs: &'b Quaternion<T>) -> Self::Output
Performs the *
operation. Read more
sourceimpl<'b, T: SimdRealField> Mul<&'b Quaternion<T>> for Quaternion<T> where
T::Element: SimdRealField,
impl<'b, T: SimdRealField> Mul<&'b Quaternion<T>> for Quaternion<T> where
T::Element: SimdRealField,
type Output = Quaternion<T>
type Output = Quaternion<T>
The resulting type after applying the *
operator.
sourcefn mul(self, rhs: &'b Quaternion<T>) -> Self::Output
fn mul(self, rhs: &'b Quaternion<T>) -> Self::Output
Performs the *
operation. Read more
sourceimpl<'b> Mul<&'b Quaternion<f32>> for f32
impl<'b> Mul<&'b Quaternion<f32>> for f32
type Output = Quaternion<f32>
type Output = Quaternion<f32>
The resulting type after applying the *
operator.
sourceimpl<'b> Mul<&'b Quaternion<f64>> for f64
impl<'b> Mul<&'b Quaternion<f64>> for f64
type Output = Quaternion<f64>
type Output = Quaternion<f64>
The resulting type after applying the *
operator.
sourceimpl<'a, T: SimdRealField> Mul<Quaternion<T>> for &'a Quaternion<T> where
T::Element: SimdRealField,
impl<'a, T: SimdRealField> Mul<Quaternion<T>> for &'a Quaternion<T> where
T::Element: SimdRealField,
type Output = Quaternion<T>
type Output = Quaternion<T>
The resulting type after applying the *
operator.
sourcefn mul(self, rhs: Quaternion<T>) -> Self::Output
fn mul(self, rhs: Quaternion<T>) -> Self::Output
Performs the *
operation. Read more
sourceimpl<T: SimdRealField> Mul<Quaternion<T>> for Quaternion<T> where
T::Element: SimdRealField,
impl<T: SimdRealField> Mul<Quaternion<T>> for Quaternion<T> where
T::Element: SimdRealField,
type Output = Quaternion<T>
type Output = Quaternion<T>
The resulting type after applying the *
operator.
sourcefn mul(self, rhs: Quaternion<T>) -> Self::Output
fn mul(self, rhs: Quaternion<T>) -> Self::Output
Performs the *
operation. Read more
sourceimpl Mul<Quaternion<f32>> for f32
impl Mul<Quaternion<f32>> for f32
type Output = Quaternion<f32>
type Output = Quaternion<f32>
The resulting type after applying the *
operator.
sourceimpl Mul<Quaternion<f64>> for f64
impl Mul<Quaternion<f64>> for f64
type Output = Quaternion<f64>
type Output = Quaternion<f64>
The resulting type after applying the *
operator.
sourceimpl<T: SimdRealField> Mul<T> for Quaternion<T> where
T::Element: SimdRealField,
impl<T: SimdRealField> Mul<T> for Quaternion<T> where
T::Element: SimdRealField,
sourceimpl<'a, T: SimdRealField> Mul<T> for &'a Quaternion<T> where
T::Element: SimdRealField,
impl<'a, T: SimdRealField> Mul<T> for &'a Quaternion<T> where
T::Element: SimdRealField,
sourceimpl<'b, T: SimdRealField> MulAssign<&'b Quaternion<T>> for Quaternion<T> where
T::Element: SimdRealField,
impl<'b, T: SimdRealField> MulAssign<&'b Quaternion<T>> for Quaternion<T> where
T::Element: SimdRealField,
sourcefn mul_assign(&mut self, rhs: &'b Quaternion<T>)
fn mul_assign(&mut self, rhs: &'b Quaternion<T>)
Performs the *=
operation. Read more
sourceimpl<T: SimdRealField> MulAssign<Quaternion<T>> for Quaternion<T> where
T::Element: SimdRealField,
impl<T: SimdRealField> MulAssign<Quaternion<T>> for Quaternion<T> where
T::Element: SimdRealField,
sourcefn mul_assign(&mut self, rhs: Quaternion<T>)
fn mul_assign(&mut self, rhs: Quaternion<T>)
Performs the *=
operation. Read more
sourceimpl<T: SimdRealField> MulAssign<T> for Quaternion<T> where
T::Element: SimdRealField,
impl<T: SimdRealField> MulAssign<T> for Quaternion<T> where
T::Element: SimdRealField,
sourcefn mul_assign(&mut self, n: T)
fn mul_assign(&mut self, n: T)
Performs the *=
operation. Read more
sourceimpl<T: SimdRealField> Neg for Quaternion<T> where
T::Element: SimdRealField,
impl<T: SimdRealField> Neg for Quaternion<T> where
T::Element: SimdRealField,
sourceimpl<'a, T: SimdRealField> Neg for &'a Quaternion<T> where
T::Element: SimdRealField,
impl<'a, T: SimdRealField> Neg for &'a Quaternion<T> where
T::Element: SimdRealField,
sourceimpl<T: SimdRealField> Normed for Quaternion<T>
impl<T: SimdRealField> Normed for Quaternion<T>
type Norm = T::SimdRealField
type Norm = T::SimdRealField
The type of the norm.
sourcefn norm(&self) -> T::SimdRealField
fn norm(&self) -> T::SimdRealField
Computes the norm.
sourcefn norm_squared(&self) -> T::SimdRealField
fn norm_squared(&self) -> T::SimdRealField
Computes the squared norm.
sourcefn unscale_mut(&mut self, n: Self::Norm)
fn unscale_mut(&mut self, n: Self::Norm)
Divides self
by n.
sourceimpl<T: SimdRealField> One for Quaternion<T> where
T::Element: SimdRealField,
impl<T: SimdRealField> One for Quaternion<T> where
T::Element: SimdRealField,
sourceimpl<T: Scalar> PartialEq<Quaternion<T>> for Quaternion<T>
impl<T: Scalar> PartialEq<Quaternion<T>> for Quaternion<T>
sourceimpl<T: RealField + RelativeEq<Epsilon = T>> RelativeEq<Quaternion<T>> for Quaternion<T>
impl<T: RealField + RelativeEq<Epsilon = T>> RelativeEq<Quaternion<T>> for Quaternion<T>
sourcefn default_max_relative() -> Self::Epsilon
fn default_max_relative() -> Self::Epsilon
The default relative tolerance for testing values that are far-apart. Read more
sourcefn relative_eq(
&self,
other: &Self,
epsilon: Self::Epsilon,
max_relative: Self::Epsilon
) -> bool
fn relative_eq(
&self,
other: &Self,
epsilon: Self::Epsilon,
max_relative: Self::Epsilon
) -> bool
A test for equality that uses a relative comparison if the values are far apart.
sourcefn relative_ne(
&self,
other: &Rhs,
epsilon: Self::Epsilon,
max_relative: Self::Epsilon
) -> bool
fn relative_ne(
&self,
other: &Rhs,
epsilon: Self::Epsilon,
max_relative: Self::Epsilon
) -> bool
The inverse of RelativeEq::relative_eq
.
sourceimpl<T: Scalar + SimdValue> SimdValue for Quaternion<T> where
T::Element: Scalar,
impl<T: Scalar + SimdValue> SimdValue for Quaternion<T> where
T::Element: Scalar,
type Element = Quaternion<T::Element>
type Element = Quaternion<T::Element>
The type of the elements of each lane of this SIMD value.
sourceunsafe fn extract_unchecked(&self, i: usize) -> Self::Element
unsafe fn extract_unchecked(&self, i: usize) -> Self::Element
Extracts the i-th lane of self
without bound-checking.
sourcefn replace(&mut self, i: usize, val: Self::Element)
fn replace(&mut self, i: usize, val: Self::Element)
Replaces the i-th lane of self
by val
. Read more
sourceunsafe fn replace_unchecked(&mut self, i: usize, val: Self::Element)
unsafe fn replace_unchecked(&mut self, i: usize, val: Self::Element)
Replaces the i-th lane of self
by val
without bound-checking.
sourcefn select(self, cond: Self::SimdBool, other: Self) -> Self
fn select(self, cond: Self::SimdBool, other: Self) -> Self
Merges self
and other
depending on the lanes of cond
. Read more
sourceimpl<'a, 'b, T: SimdRealField> Sub<&'b Quaternion<T>> for &'a Quaternion<T> where
T::Element: SimdRealField,
impl<'a, 'b, T: SimdRealField> Sub<&'b Quaternion<T>> for &'a Quaternion<T> where
T::Element: SimdRealField,
type Output = Quaternion<T>
type Output = Quaternion<T>
The resulting type after applying the -
operator.
sourcefn sub(self, rhs: &'b Quaternion<T>) -> Self::Output
fn sub(self, rhs: &'b Quaternion<T>) -> Self::Output
Performs the -
operation. Read more
sourceimpl<'b, T: SimdRealField> Sub<&'b Quaternion<T>> for Quaternion<T> where
T::Element: SimdRealField,
impl<'b, T: SimdRealField> Sub<&'b Quaternion<T>> for Quaternion<T> where
T::Element: SimdRealField,
type Output = Quaternion<T>
type Output = Quaternion<T>
The resulting type after applying the -
operator.
sourcefn sub(self, rhs: &'b Quaternion<T>) -> Self::Output
fn sub(self, rhs: &'b Quaternion<T>) -> Self::Output
Performs the -
operation. Read more
sourceimpl<'a, T: SimdRealField> Sub<Quaternion<T>> for &'a Quaternion<T> where
T::Element: SimdRealField,
impl<'a, T: SimdRealField> Sub<Quaternion<T>> for &'a Quaternion<T> where
T::Element: SimdRealField,
type Output = Quaternion<T>
type Output = Quaternion<T>
The resulting type after applying the -
operator.
sourcefn sub(self, rhs: Quaternion<T>) -> Self::Output
fn sub(self, rhs: Quaternion<T>) -> Self::Output
Performs the -
operation. Read more
sourceimpl<T: SimdRealField> Sub<Quaternion<T>> for Quaternion<T> where
T::Element: SimdRealField,
impl<T: SimdRealField> Sub<Quaternion<T>> for Quaternion<T> where
T::Element: SimdRealField,
type Output = Quaternion<T>
type Output = Quaternion<T>
The resulting type after applying the -
operator.
sourcefn sub(self, rhs: Quaternion<T>) -> Self::Output
fn sub(self, rhs: Quaternion<T>) -> Self::Output
Performs the -
operation. Read more
sourceimpl<'b, T: SimdRealField> SubAssign<&'b Quaternion<T>> for Quaternion<T> where
T::Element: SimdRealField,
impl<'b, T: SimdRealField> SubAssign<&'b Quaternion<T>> for Quaternion<T> where
T::Element: SimdRealField,
sourcefn sub_assign(&mut self, rhs: &'b Quaternion<T>)
fn sub_assign(&mut self, rhs: &'b Quaternion<T>)
Performs the -=
operation. Read more
sourceimpl<T: SimdRealField> SubAssign<Quaternion<T>> for Quaternion<T> where
T::Element: SimdRealField,
impl<T: SimdRealField> SubAssign<Quaternion<T>> for Quaternion<T> where
T::Element: SimdRealField,
sourcefn sub_assign(&mut self, rhs: Quaternion<T>)
fn sub_assign(&mut self, rhs: Quaternion<T>)
Performs the -=
operation. Read more
sourceimpl<T1, T2> SubsetOf<Quaternion<T2>> for Quaternion<T1> where
T1: Scalar,
T2: Scalar + SupersetOf<T1>,
impl<T1, T2> SubsetOf<Quaternion<T2>> for Quaternion<T1> where
T1: Scalar,
T2: Scalar + SupersetOf<T1>,
sourcefn to_superset(&self) -> Quaternion<T2>
fn to_superset(&self) -> Quaternion<T2>
The inclusion map: converts self
to the equivalent element of its superset.
sourcefn is_in_subset(q: &Quaternion<T2>) -> bool
fn is_in_subset(q: &Quaternion<T2>) -> bool
Checks if element
is actually part of the subset Self
(and can be converted to it).
sourcefn from_superset_unchecked(q: &Quaternion<T2>) -> Self
fn from_superset_unchecked(q: &Quaternion<T2>) -> Self
Use with care! Same as self.to_superset
but without any property checks. Always succeeds.
sourcefn from_superset(element: &T) -> Option<Self>
fn from_superset(element: &T) -> Option<Self>
The inverse inclusion map: attempts to construct self
from the equivalent element of its
superset. Read more
sourceimpl<T: RealField + UlpsEq<Epsilon = T>> UlpsEq<Quaternion<T>> for Quaternion<T>
impl<T: RealField + UlpsEq<Epsilon = T>> UlpsEq<Quaternion<T>> for Quaternion<T>
sourceimpl<T: SimdRealField> Zero for Quaternion<T> where
T::Element: SimdRealField,
impl<T: SimdRealField> Zero for Quaternion<T> where
T::Element: SimdRealField,
impl<T: Copy> Copy for Quaternion<T>
impl<T: Scalar + Eq> Eq for Quaternion<T>
Auto Trait Implementations
impl<T> RefUnwindSafe for Quaternion<T> where
T: RefUnwindSafe,
impl<T> Send for Quaternion<T> where
T: Send,
impl<T> Sync for Quaternion<T> where
T: Sync,
impl<T> Unpin for Quaternion<T> where
T: Unpin,
impl<T> UnwindSafe for Quaternion<T> where
T: UnwindSafe,
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcepub fn borrow_mut(&mut self) -> &mut T
pub fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<SS, SP> SupersetOf<SS> for SP where
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SP where
SS: SubsetOf<SP>,
sourcepub fn to_subset(&self) -> Option<SS>
pub fn to_subset(&self) -> Option<SS>
The inverse inclusion map: attempts to construct self
from the equivalent element of its
superset. Read more
sourcepub fn is_in_subset(&self) -> bool
pub fn is_in_subset(&self) -> bool
Checks if self
is actually part of its subset T
(and can be converted to it).
sourcepub fn to_subset_unchecked(&self) -> SS
pub fn to_subset_unchecked(&self) -> SS
Use with care! Same as self.to_subset
but without any property checks. Always succeeds.
sourcepub fn from_subset(element: &SS) -> SP
pub fn from_subset(element: &SS) -> SP
The inclusion map: converts self
to the equivalent element of its superset.
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcepub fn to_owned(&self) -> T
pub fn to_owned(&self) -> T
Creates owned data from borrowed data, usually by cloning. Read more
sourcepub fn clone_into(&self, target: &mut T)
pub fn clone_into(&self, target: &mut T)
toowned_clone_into
)Uses borrowed data to replace owned data, usually by cloning. Read more