# [−][src]Struct nalgebra::geometry::Quaternion

    #[repr(C)]
    pub struct Quaternion<N: RealField> {
        pub coords: Vector4<N>,
    }

A quaternion. See the type alias `UnitQuaternion = Unit<Quaternion>` for a quaternion that may be used as a rotation.

## Fields

`coords: Vector4<N>`

This quaternion as a 4D vector of coordinates in the `[ x, y, z, w ]` storage order.

## Methods

### `impl<N: RealField> Quaternion<N>`[src]

#### `pub fn into_owned(self) -> Self`[src]

Deprecated:

This method is a no-op and will be removed in a future release.

Moves this unit quaternion into one that owns its data.

#### `pub fn clone_owned(&self) -> Self`[src]

Deprecated:

This method is a no-op and will be removed in a future release.

Clones this unit quaternion into one that owns its data.

#### `pub fn normalize(&self) -> Self`[src]

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);

#### `pub fn imag(&self) -> Vector3<N>`[src]

The imaginary part of this quaternion.

#### `pub fn conjugate(&self) -> Self`[src]

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);

#### `pub fn try_inverse(&self) -> Option<Self>`[src]

Inverts this quaternion if it is not zero.

# 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());

#### `pub fn lerp(&self, other: &Self, t: N) -> Self`[src]

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));

#### `pub fn vector(
&self
) -> MatrixSlice<N, U3, U1, RStride<N, U4, U1>, CStride<N, U4, U1>>`[src]

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);

#### `pub fn scalar(&self) -> N`[src]

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);

#### `pub fn as_vector(&self) -> &Vector4<N>`[src]

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));

#### `pub fn norm(&self) -> N`[src]

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);

#### `pub fn magnitude(&self) -> N`[src]

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);

#### `pub fn norm_squared(&self) -> N`[src]

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);

#### `pub fn magnitude_squared(&self) -> N`[src]

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);

#### `pub fn dot(&self, rhs: &Self) -> N`[src]

The dot product of two quaternions.

# Example

    let q1 = Quaternion::new(1.0, 2.0, 3.0, 4.0);
    let q2 = Quaternion::new(5.0, 6.0, 7.0, 8.0);
    assert_eq!(q1.dot(&q2), 70.0);

#### `pub fn inner(&self, other: &Self) -> Self`[src]

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);

#### `pub fn outer(&self, other: &Self) -> Self`[src]

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);

#### `pub fn project(&self, other: &Self) -> Option<Self>`[src]

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);

#### `pub fn reject(&self, other: &Self) -> Option<Self>`[src]

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);

#### `pub fn polar_decomposition(&self) -> (N, N, Option<Unit<Vector3<N>>>)`[src]

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()));

#### `pub fn ln(&self) -> Self`[src]

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)

#### `pub fn exp(&self) -> Self`[src]

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)

#### `pub fn exp_eps(&self, eps: N) -> Self`[src]

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());

#### `pub fn powf(&self, n: N) -> Self`[src]

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);

#### `pub fn as_vector_mut(&mut self) -> &mut Vector4<N>`[src]

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);

#### `pub fn vector_mut(
&mut self
) -> MatrixSliceMut<N, U3, U1, RStride<N, U4, U1>, CStride<N, U4, U1>>`[src]

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);

#### `pub fn conjugate_mut(&mut self)`[src]

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);

#### `pub fn try_inverse_mut(&mut self) -> bool`[src]

Inverts this quaternion in-place if it is not zero.

# Example

    let mut q = Quaternion::new(1.0, 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.0, 0.0, 0.0, 0.0);
    assert!(!q.try_inverse_mut());

#### `pub fn normalize_mut(&mut self) -> N`[src]

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);

#### `pub fn squared(&self) -> Self`[src]

Calculates square of a quaternion.

#### `pub fn half(&self) -> Self`[src]

Divides quaternion into two.

#### `pub fn sqrt(&self) -> Self`[src]

Calculates square root.

#### `pub fn is_pure(&self) -> bool`[src]

Check if the quaternion is pure.

#### `pub fn pure(&self) -> Self`[src]

Convert quaternion to pure quaternion.

#### `pub fn left_div(&self, other: &Self) -> Option<Self>`[src]

Left quaternionic division.

Calculates B-1 * A where A = self, B = other.

#### `pub fn right_div(&self, other: &Self) -> Option<Self>`[src]

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);

#### `pub fn cos(&self) -> Self`[src]

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);

#### `pub fn acos(&self) -> Self`[src]

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);

#### `pub fn sin(&self) -> Self`[src]

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);

#### `pub fn asin(&self) -> Self`[src]

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);

#### `pub fn tan(&self) -> Self`[src]

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);

#### `pub fn atan(&self) -> Self`[src]

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);

#### `pub fn sinh(&self) -> Self`[src]

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);

#### `pub fn asinh(&self) -> Self`[src]

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);

#### `pub fn cosh(&self) -> Self`[src]

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);

#### `pub fn acosh(&self) -> Self`[src]

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);

#### `pub fn tanh(&self) -> Self`[src]

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);

#### `pub fn atanh(&self) -> Self`[src]

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);

### `impl<N: RealField> Quaternion<N>`[src]

#### `pub fn from_vector(vector: Vector4<N>) -> Self`[src]

Deprecated:

Use `::from` instead.

Creates a quaternion from a 4D vector. The quaternion scalar part corresponds to the `w` vector component.

#### `pub fn new(w: N, i: N, j: N, k: N) -> Self`[src]

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));

#### `pub fn from_imag(vector: Vector3<N>) -> Self`[src]

Constructs a pure quaternion.

#### `pub fn from_parts<SB>(scalar: N, vector: Vector<N, U3, SB>) -> Self where
SB: Storage<N, U3>,` [src]

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));

#### `pub fn from_real(r: N) -> Self`[src]

Constructs a real quaternion.

#### `pub fn from_polar_decomposition<SB>(
scale: N,
theta: N,
axis: Unit<Vector<N, U3, SB>>
) -> Self where
SB: Storage<N, U3>,` [src]

Creates a new quaternion from its polar decomposition.

Note that `axis` is assumed to be a unit vector.

#### `pub fn identity() -> Self`[src]

The quaternion multiplicative identity.

# Example

    let q = Quaternion::identity();
    let q2 = Quaternion::new(1.0, 2.0, 3.0, 4.0);

    assert_eq!(q * q2, q2);
    assert_eq!(q2 * q, q2);

## Trait Implementations

### `impl<N: RealField + Eq> Eq for Quaternion<N>`[src]

### `impl<N: RealField> Clone for Quaternion<N>`[src]

#### `fn clone(&self) -> Self`[src]

Returns a copy of the value. Read more

#### `fn clone_from(&mut self, source: &Self)`1.0.0[src]

Performs copy-assignment from `source`. Read more

### `impl<N: RealField> PartialEq<Quaternion<N>> for Quaternion<N>`[src]

#### `fn eq(&self, rhs: &Self) -> bool`[src]

This method tests for `self` and `other` values to be equal, and is used by `==`. Read more

#### `#[must_use] fn ne(&self, other: &Rhs) -> bool` 1.0.0[src]

This method tests for `!=`.

### `impl<N: RealField> From<Matrix<N, U4, U1, <DefaultAllocator as Allocator<N, U4, U1>>::Buffer>> for Quaternion<N>`[src]

#### `fn from(coords: Vector4<N>) -> Self`[src]

Performs the conversion.

### `impl<N: RealField> Copy for Quaternion<N>`[src]

### `impl<N: RealField> DerefMut for Quaternion<N>`[src]

#### `fn deref_mut(&mut self) -> &mut Self::Target`[src]

Mutably dereferences the value.

### `impl<N: RealField + Hash> Hash for Quaternion<N>`[src]

#### `fn hash<H: Hasher>(&self, state: &mut H)`[src]

Feeds this value into the given [`Hasher`]. Read more

#### `fn hash_slice<H>(data: &[Self], state: &mut H) where
H: Hasher,` 1.3.0[src]

Feeds a slice of this type into the given [`Hasher`]. Read more

### `impl<'a, 'b, N: RealField> Add<&'b Quaternion<N>> for &'a Quaternion<N> where
DefaultAllocator: Allocator<N, U4, U1>,` [src]

#### `type Output = Quaternion<N>`

The resulting type after applying the `+` operator.

#### `fn add(self, rhs: &'b Quaternion<N>) -> Self::Output`[src]

Performs the `+` operation.

### `impl<'a, N: RealField> Add<Quaternion<N>> for &'a Quaternion<N> where
DefaultAllocator: Allocator<N, U4, U1>,` [src]

#### `type Output = Quaternion<N>`

The resulting type after applying the `+` operator.

#### `fn add(self, rhs: Quaternion<N>) -> Self::Output`[src]

Performs the `+` operation.

### `impl<'b, N: RealField> Add<&'b Quaternion<N>> for Quaternion<N> where
DefaultAllocator: Allocator<N, U4, U1>,` [src]

#### `type Output = Quaternion<N>`

The resulting type after applying the `+` operator.

#### `fn add(self, rhs: &'b Quaternion<N>) -> Self::Output`[src]

Performs the `+` operation.

### `impl<N: RealField> Add<Quaternion<N>> for Quaternion<N> where
DefaultAllocator: Allocator<N, U4, U1>,` [src]

#### `type Output = Quaternion<N>`

The resulting type after applying the `+` operator.

#### `fn add(self, rhs: Quaternion<N>) -> Self::Output`[src]

Performs the `+` operation.

### `impl<'a, 'b, N: RealField> Sub<&'b Quaternion<N>> for &'a Quaternion<N> where
DefaultAllocator: Allocator<N, U4, U1>,` [src]

#### `type Output = Quaternion<N>`

The resulting type after applying the `-` operator.

#### `fn sub(self, rhs: &'b Quaternion<N>) -> Self::Output`[src]

Performs the `-` operation.

### `impl<'a, N: RealField> Sub<Quaternion<N>> for &'a Quaternion<N> where
DefaultAllocator: Allocator<N, U4, U1>,` [src]

#### `type Output = Quaternion<N>`

The resulting type after applying the `-` operator.

#### `fn sub(self, rhs: Quaternion<N>) -> Self::Output`[src]

Performs the `-` operation.

### `impl<'b, N: RealField> Sub<&'b Quaternion<N>> for Quaternion<N> where
DefaultAllocator: Allocator<N, U4, U1>,` [src]

#### `type Output = Quaternion<N>`

The resulting type after applying the `-` operator.

#### `fn sub(self, rhs: &'b Quaternion<N>) -> Self::Output`[src]

Performs the `-` operation.

### `impl<N: RealField> Sub<Quaternion<N>> for Quaternion<N> where
DefaultAllocator: Allocator<N, U4, U1>,` [src]

#### `type Output = Quaternion<N>`

The resulting type after applying the `-` operator.

#### `fn sub(self, rhs: Quaternion<N>) -> Self::Output`[src]

Performs the `-` operation.

### `impl<'a, 'b, N: RealField> Mul<&'b Quaternion<N>> for &'a Quaternion<N> where
DefaultAllocator: Allocator<N, U4, U1>,` [src]

#### `type Output = Quaternion<N>`

The resulting type after applying the `*` operator.

#### `fn mul(self, rhs: &'b Quaternion<N>) -> Self::Output`[src]

Performs the `*` operation.

### `impl<'a, N: RealField> Mul<Quaternion<N>> for &'a Quaternion<N> where
DefaultAllocator: Allocator<N, U4, U1>,` [src]

#### `type Output = Quaternion<N>`

The resulting type after applying the `*` operator.

#### `fn mul(self, rhs: Quaternion<N>) -> Self::Output`[src]

Performs the `*` operation.

### `impl<'b, N: RealField> Mul<&'b Quaternion<N>> for Quaternion<N> where
DefaultAllocator: Allocator<N, U4, U1>,` [src]

#### `type Output = Quaternion<N>`

The resulting type after applying the `*` operator.

#### `fn mul(self, rhs: &'b Quaternion<N>) -> Self::Output`[src]

Performs the `*` operation.

### `impl<N: RealField> Mul<Quaternion<N>> for Quaternion<N> where
DefaultAllocator: Allocator<N, U4, U1>,` [src]

#### `type Output = Quaternion<N>`

The resulting type after applying the `*` operator.

#### `fn mul(self, rhs: Quaternion<N>) -> Self::Output`[src]

Performs the `*` operation.

### `impl<N: RealField> Mul<N> for Quaternion<N>`[src]

#### `type Output = Quaternion<N>`

The resulting type after applying the `*` operator.

#### `fn mul(self, n: N) -> Self::Output`[src]

Performs the `*` operation.

### `impl<'a, N: RealField> Mul<N> for &'a Quaternion<N>`[src]

#### `type Output = Quaternion<N>`

The resulting type after applying the `*` operator.

#### `fn mul(self, n: N) -> Self::Output`[src]

Performs the `*` operation.

### `impl Mul<Quaternion<f32>> for f32`[src]

#### `type Output = Quaternion<f32>`

The resulting type after applying the `*` operator.

#### `fn mul(self, right: Quaternion<f32>) -> Self::Output`[src]

Performs the `*` operation.

### `impl<'b> Mul<&'b Quaternion<f32>> for f32`[src]

#### `type Output = Quaternion<f32>`

The resulting type after applying the `*` operator.

#### `fn mul(self, right: &'b Quaternion<f32>) -> Self::Output`[src]

Performs the `*` operation.

### `impl Mul<Quaternion<f64>> for f64`[src]

#### `type Output = Quaternion<f64>`

The resulting type after applying the `*` operator.

#### `fn mul(self, right: Quaternion<f64>) -> Self::Output`[src]

Performs the `*` operation.

### `impl<'b> Mul<&'b Quaternion<f64>> for f64`[src]

#### `type Output = Quaternion<f64>`

The resulting type after applying the `*` operator.

#### `fn mul(self, right: &'b Quaternion<f64>) -> Self::Output`[src]

Performs the `*` operation.

### `impl<N: RealField> Div<N> for Quaternion<N>`[src]

#### `type Output = Quaternion<N>`

The resulting type after applying the `/` operator.

#### `fn div(self, n: N) -> Self::Output`[src]

Performs the `/` operation.

### `impl<'a, N: RealField> Div<N> for &'a Quaternion<N>`[src]

#### `type Output = Quaternion<N>`

The resulting type after applying the `/` operator.

#### `fn div(self, n: N) -> Self::Output`[src]

Performs the `/` operation.

### `impl<N: RealField> Neg for Quaternion<N>`[src]

#### `type Output = Quaternion<N>`

The resulting type after applying the `-` operator.

#### `fn neg(self) -> Self::Output`[src]

Performs the unary `-` operation.

### `impl<'a, N: RealField> Neg for &'a Quaternion<N>`[src]

#### `type Output = Quaternion<N>`

The resulting type after applying the `-` operator.

#### `fn neg(self) -> Self::Output`[src]

Performs the unary `-` operation.

### `impl<'b, N: RealField> AddAssign<&'b Quaternion<N>> for Quaternion<N> where
DefaultAllocator: Allocator<N, U4, U1>,` [src]

#### `fn add_assign(&mut self, rhs: &'b Quaternion<N>)`[src]

Performs the `+=` operation.

### `impl<N: RealField> AddAssign<Quaternion<N>> for Quaternion<N> where
DefaultAllocator: Allocator<N, U4, U1>,` [src]

#### `fn add_assign(&mut self, rhs: Quaternion<N>)`[src]

Performs the `+=` operation.

### `impl<'b, N: RealField> SubAssign<&'b Quaternion<N>> for Quaternion<N> where
DefaultAllocator: Allocator<N, U4, U1>,` [src]

#### `fn sub_assign(&mut self, rhs: &'b Quaternion<N>)`[src]

Performs the `-=` operation.

### `impl<N: RealField> SubAssign<Quaternion<N>> for Quaternion<N> where
DefaultAllocator: Allocator<N, U4, U1>,` [src]

#### `fn sub_assign(&mut self, rhs: Quaternion<N>)`[src]

Performs the `-=` operation.

### `impl<N: RealField> MulAssign<N> for Quaternion<N>`[src]

#### `fn mul_assign(&mut self, n: N)`[src]

Performs the `*=` operation.

### `impl<'b, N: RealField> MulAssign<&'b Quaternion<N>> for Quaternion<N> where
DefaultAllocator: Allocator<N, U4, U1>,` [src]

#### `fn mul_assign(&mut self, rhs: &'b Quaternion<N>)`[src]

Performs the `*=` operation.

### `impl<N: RealField> MulAssign<Quaternion<N>> for Quaternion<N> where
DefaultAllocator: Allocator<N, U4, U1>,` [src]

#### `fn mul_assign(&mut self, rhs: Quaternion<N>)`[src]

Performs the `*=` operation.

### `impl<N: RealField> DivAssign<N> for Quaternion<N>`[src]

#### `fn div_assign(&mut self, n: N)`[src]

Performs the `/=` operation.

### `impl<N: RealField> Deref for Quaternion<N>`[src]

#### `type Target = IJKW<N>`

The resulting type after dereferencing.

#### `fn deref(&self) -> &Self::Target`[src]

Dereferences the value.

### `impl<N: RealField> Index<usize> for Quaternion<N>`[src]

#### `type Output = N`

The returned type after indexing.

#### `fn index(&self, i: usize) -> &Self::Output`[src]

Performs the indexing (`container[index]`) operation.

### `impl<N: RealField> IndexMut<usize> for Quaternion<N>`[src]

#### `fn index_mut(&mut self, i: usize) -> &mut N`[src]

Performs the mutable indexing (`container[index]`) operation.

### `impl<N: Debug + RealField> Debug for Quaternion<N>`[src]

#### `fn fmt(&self, f: &mut Formatter) -> Result`[src]

Formats the value using the given formatter. Read more

### `impl<N: RealField + Display> Display for Quaternion<N>`[src]

#### `fn fmt(&self, f: &mut Formatter) -> Result`[src]

Formats the value using the given formatter. Read more

### `impl<N: RealField + AbsDiffEq<Epsilon = N>> AbsDiffEq<Quaternion<N>> for Quaternion<N>`[src]

#### `type Epsilon = N`

Used for specifying relative comparisons.

#### `fn default_epsilon() -> Self::Epsilon`[src]

The default tolerance to use when testing values that are close together. Read more

#### `fn abs_diff_eq(&self, other: &Self, epsilon: Self::Epsilon) -> bool`[src]

A test for equality that uses the absolute difference to compute the approximate equality of two numbers. Read more

#### `fn abs_diff_ne(&self, other: &Rhs, epsilon: Self::Epsilon) -> bool`[src]

The inverse of `ApproxEq::abs_diff_eq`.

### `impl<N: RealField + RelativeEq<Epsilon = N>> RelativeEq<Quaternion<N>> for Quaternion<N>`[src]

#### `fn default_max_relative() -> Self::Epsilon`[src]

The default relative tolerance for testing values that are far-apart. Read more

#### `fn relative_eq(
&self,
other: &Self,
epsilon: Self::Epsilon,
max_relative: Self::Epsilon
) -> bool`[src]

A test for equality that uses a relative comparison if the values are far apart.

#### `fn relative_ne(
&self,
other: &Rhs,
epsilon: Self::Epsilon,
max_relative: Self::Epsilon
) -> bool`[src]

The inverse of `ApproxEq::relative_eq`.

### `impl<N: RealField + UlpsEq<Epsilon = N>> UlpsEq<Quaternion<N>> for Quaternion<N>`[src]

#### `fn default_max_ulps() -> u32`[src]

The default ULPs to tolerate when testing values that are far-apart. Read more

#### `fn ulps_eq(&self, other: &Self, epsilon: Self::Epsilon, max_ulps: u32) -> bool`[src]

A test for equality that uses units in the last place (ULP) if the values are far apart.

#### `fn ulps_ne(&self, other: &Rhs, epsilon: Self::Epsilon, max_ulps: u32) -> bool`[src]

The inverse of `ApproxEq::ulps_eq`.

### `impl<N: RealField> Zero for Quaternion<N>`[src]

#### `fn zero() -> Self`[src]

Returns the additive identity element of `Self`, `0`. # Purity Read more

#### `fn is_zero(&self) -> bool`[src]

Returns `true` if `self` is equal to the additive identity.

#### `fn set_zero(&mut self)`[src]

Sets `self` to the additive identity element of `Self`, `0`.

### `impl<N: RealField> One for Quaternion<N>`[src]

#### `fn one() -> Self`[src]

Returns the multiplicative identity element of `Self`, `1`. Read more

#### `fn set_one(&mut self)`[src]

Sets `self` to the multiplicative identity element of `Self`, `1`.

#### `fn is_one(&self) -> bool where
Self: PartialEq<Self>,` [src]

Returns `true` if `self` is equal to the multiplicative identity. Read more

### `impl<N: RealField> Distribution<Quaternion<N>> for Standard where
Standard: Distribution<N>,` [src]

#### `fn sample<'a, R: Rng + ?Sized>(&self, rng: &'a mut R) -> Quaternion<N>`[src]

Generate a random value of `T`, using `rng` as the source of randomness.

#### `fn sample_iter<R>(&'a self, rng: &'a mut R) -> DistIter<'a, Self, R, T> where
R: Rng,` [src]

Create an iterator that generates random values of `T`, using `rng` as the source of randomness. Read more

### `impl<N: RealField> AbstractMagma<Multiplicative> for Quaternion<N>`[src]

#### `fn operate(&self, rhs: &Self) -> Self`[src]

Performs an operation.

#### `fn op(&self, O, lhs: &Self) -> Self`[src]

Performs specific operation.

### `impl<N: RealField> AbstractMagma<Additive> for Quaternion<N>`[src]

#### `fn operate(&self, rhs: &Self) -> Self`[src]

Performs an operation.

#### `fn op(&self, O, lhs: &Self) -> Self`[src]

Performs specific operation.

### `impl<N: RealField> AbstractQuasigroup<Additive> for Quaternion<N>`[src]

#### `fn prop_inv_is_latin_square_approx(args: (Self, Self)) -> bool where
Self: RelativeEq<Self>,` [src]

Returns `true` if latin squareness holds for the given arguments. Approximate equality is used for verifications. Read more

#### `fn prop_inv_is_latin_square(args: (Self, Self)) -> bool where
Self: Eq,` [src]

Returns `true` if latin squareness holds for the given arguments. Read more

### `impl<N: RealField> AbstractSemigroup<Multiplicative> for Quaternion<N>`[src]

#### `fn prop_is_associative_approx(args: (Self, Self, Self)) -> bool where
Self: RelativeEq<Self>,` [src]

Returns `true` if associativity holds for the given arguments. Approximate equality is used for verifications. Read more

#### `fn prop_is_associative(args: (Self, Self, Self)) -> bool where
Self: Eq,` [src]

Returns `true` if associativity holds for the given arguments.

### `impl<N: RealField> AbstractSemigroup<Additive> for Quaternion<N>`[src]

#### `fn prop_is_associative_approx(args: (Self, Self, Self)) -> bool where
Self: RelativeEq<Self>,` [src]

Returns `true` if associativity holds for the given arguments. Approximate equality is used for verifications. Read more

#### `fn prop_is_associative(args: (Self, Self, Self)) -> bool where
Self: Eq,` [src]

Returns `true` if associativity holds for the given arguments.

### `impl<N: RealField> AbstractLoop<Additive> for Quaternion<N>`[src]

### `impl<N: RealField> AbstractMonoid<Multiplicative> for Quaternion<N>`[src]

#### `fn prop_operating_identity_element_is_noop_approx(args: (Self,)) -> bool where
Self: RelativeEq<Self>,` [src]

Checks whether operating with the identity element is a no-op for the given argument. Approximate equality is used for verifications. Read more

#### `fn prop_operating_identity_element_is_noop(args: (Self,)) -> bool where
Self: Eq,` [src]

Checks whether operating with the identity element is a no-op for the given argument. Read more

### `impl<N: RealField> AbstractMonoid<Additive> for Quaternion<N>`[src]

#### `fn prop_operating_identity_element_is_noop_approx(args: (Self,)) -> bool where
Self: RelativeEq<Self>,` [src]

Checks whether operating with the identity element is a no-op for the given argument. Approximate equality is used for verifications. Read more

#### `fn prop_operating_identity_element_is_noop(args: (Self,)) -> bool where
Self: Eq,` [src]

Checks whether operating with the identity element is a no-op for the given argument. Read more

### `impl<N: RealField> AbstractGroup<Additive> for Quaternion<N>`[src]

### `impl<N: RealField> AbstractGroupAbelian<Additive> for Quaternion<N>`[src]

#### `fn prop_is_commutative_approx(args: (Self, Self)) -> bool where
Self: RelativeEq<Self>,` [src]

Returns `true` if the operator is commutative for the given argument tuple. Approximate equality is used for verifications. Read more

#### `fn prop_is_commutative(args: (Self, Self)) -> bool where
Self: Eq,` [src]

Returns `true` if the operator is commutative for the given argument tuple.

### `impl<N: RealField> Identity<Multiplicative> for Quaternion<N>`[src]

#### `fn identity() -> Self`[src]

The identity element.

#### `fn id(O) -> Self`[src]

Specific identity.

### `impl<N: RealField> Identity<Additive> for Quaternion<N>`[src]

#### `fn identity() -> Self`[src]

The identity element.

#### `fn id(O) -> Self`[src]

Specific identity.

### `impl<N: RealField> TwoSidedInverse<Additive> for Quaternion<N>`[src]

#### `fn two_sided_inverse(&self) -> Self`[src]

Returns the two_sided_inverse of `self`, relative to the operator `O`. Read more

#### `fn two_sided_inverse_mut(&mut self)`[src]

In-place inversion of `self`, relative to the operator `O`. Read more

### `impl<N1, N2> SubsetOf<Quaternion<N2>> for Quaternion<N1> where
N1: RealField,
N2: RealField + SupersetOf<N1>,` [src]

#### `fn to_superset(&self) -> Quaternion<N2>`[src]

The inclusion map: converts `self` to the equivalent element of its superset.

#### `fn is_in_subset(q: &Quaternion<N2>) -> bool`[src]

Checks if `element` is actually part of the subset `Self` (and can be converted to it).

#### `unsafe fn from_superset_unchecked(q: &Quaternion<N2>) -> Self`[src]

Use with care! Same as `self.to_superset` but without any property checks. Always succeeds.

#### `fn from_superset(element: &T) -> Option<Self>`[src]

The inverse inclusion map: attempts to construct `self` from the equivalent element of its superset. Read more

### `impl<N: RealField> AbstractModule<Additive, Additive, Multiplicative> for Quaternion<N>`[src]

#### `type AbstractRing = N`

The underlying scalar field.

#### `fn multiply_by(&self, n: N) -> Self`[src]

Multiplies an element of the ring with an element of the module.

### `impl<N: RealField> Module for Quaternion<N>`[src]

#### `type Ring = N`

The underlying scalar field.

### `impl<N: RealField> FiniteDimVectorSpace for Quaternion<N>`[src]

#### `fn dimension() -> usize`[src]

The vector space dimension.

#### `fn canonical_basis_element(i: usize) -> Self`[src]

The i-the canonical basis element.

#### `fn dot(&self, other: &Self) -> N`[src]

The dot product between two vectors.

#### `unsafe fn component_unchecked(&self, i: usize) -> &N`[src]

Same as `&self[i]` but without bound-checking.

#### `unsafe fn component_unchecked_mut(&mut self, i: usize) -> &mut N`[src]

Same as `&mut self[i]` but without bound-checking.

#### `fn canonical_basis<F>(f: F) where
F: FnMut(&Self) -> bool,` [src]

Applies the given closule to each element of this vector space's canonical basis. Stops if `f` returns `false`. Read more

### `impl<N: RealField> NormedSpace for Quaternion<N>`[src]

#### `type RealField = N`

The result of the norm (not necessarily the same same as the field used by this vector space).

#### `type ComplexField = N`

The field of this space must be this complex number.

#### `fn norm_squared(&self) -> N`[src]

The squared norm of this vector.

#### `fn norm(&self) -> N`[src]

The norm of this vector.

#### `fn normalize(&self) -> Self`[src]

Returns a normalized version of this vector.

#### `fn normalize_mut(&mut self) -> N`[src]

Normalizes this vector in-place and returns its norm.

#### `fn try_normalize(&self, min_norm: N) -> Option<Self>`[src]

Returns a normalized version of this vector unless its norm as smaller or equal to `eps`.

#### `fn try_normalize_mut(&mut self, min_norm: N) -> Option<N>`[src]

Normalizes this vector in-place or does nothing if its norm is smaller or equal to `eps`. Read more

### `impl<N: RealField> VectorSpace for Quaternion<N>`[src]

#### `type Field = N`

The underlying scalar field.

## Auto Trait Implementations

### `impl<N> Send for Quaternion<N> where
N: Scalar,`

### `impl<N> Unpin for Quaternion<N> where
N: Scalar + Unpin,`

### `impl<N> Sync for Quaternion<N> where
N: Scalar,`

### `impl<N> UnwindSafe for Quaternion<N> where
N: Scalar + UnwindSafe,`

### `impl<N> RefUnwindSafe for Quaternion<N> where
N: RefUnwindSafe + Scalar,`

## Blanket Implementations

### `impl<T> ToOwned for T where
T: Clone,` [src]

#### `type Owned = T`

The resulting type after obtaining ownership.

#### `fn to_owned(&self) -> T`[src]

Creates owned data from borrowed data, usually by cloning. Read more

#### `fn clone_into(&self, target: &mut T)`[src]

🔬 This is a nightly-only experimental API. (`toowned_clone_into`)

recently added

Uses borrowed data to replace owned data, usually by cloning. Read more

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

#### `fn into(self) -> U`[src]

Performs the conversion.

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

#### `fn from(t: T) -> T`[src]

Performs the conversion.

### `impl<T> ToString for T where
T: Display + ?Sized,` [src]

#### `default fn to_string(&self) -> String`[src]

Converts the given value to a `String`. Read more

### `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.

#### `fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>`[src]

Performs the conversion.

### `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.

#### `fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>`[src]

Performs the conversion.

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

#### `fn borrow_mut(&mut self) -> &mut T`[src]

Mutably borrows from an owned value. Read more

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

#### `fn borrow(&self) -> &T`[src]

Immutably borrows from an owned value. Read more

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

#### `fn type_id(&self) -> TypeId`[src]

Gets the `TypeId` of `self`. Read more

### `impl<T> Same<T> for T`[src]

#### `type Output = T`

Should always be `Self`

### `impl<T> ClosedNeg for T where
T: Neg<Output = T>,` [src]

### `impl<SS, SP> SupersetOf<SS> for SP where
SS: SubsetOf<SP>,` [src]

#### `fn to_subset(&self) -> Option<SS>`[src]

The inverse inclusion map: attempts to construct `self` from the equivalent element of its superset. Read more

#### `fn is_in_subset(&self) -> bool`[src]

Checks if `self` is actually part of its subset `T` (and can be converted to it).

#### `unsafe fn to_subset_unchecked(&self) -> SS`[src]

Use with care! Same as `self.to_subset` but without any property checks. Always succeeds.

#### `fn from_subset(element: &SS) -> SP`[src]

The inclusion map: converts `self` to the equivalent element of its superset.

### `impl<T, Right> ClosedAdd<Right> for T where
T: Add<Right, Output = T> + AddAssign<Right>,` [src]

### `impl<T, Right> ClosedSub<Right> for T where
T: Sub<Right, Output = T> + SubAssign<Right>,` [src]

### `impl<T, Right> ClosedMul<Right> for T where
T: Mul<Right, Output = T> + MulAssign<Right>,` [src]

### `impl<T, Right> ClosedDiv<Right> for T where
T: Div<Right, Output = T> + DivAssign<Right>,` [src]

### `impl<T> AdditiveMagma for T where
T: AbstractMagma<Additive>,` [src]

### `impl<T> AdditiveQuasigroup for T where
T: AbstractQuasigroup<Additive> + ClosedSub<T> + AdditiveMagma,` [src]

### `impl<T> AdditiveLoop for T where
T: AbstractLoop<Additive> + ClosedNeg + AdditiveQuasigroup + Zero,` [src]

### `impl<T> AdditiveSemigroup for T where
T: AbstractSemigroup<Additive> + ClosedAdd<T> + AdditiveMagma,` [src]

### `impl<T> AdditiveMonoid for T where
T: AbstractMonoid<Additive> + AdditiveSemigroup + Zero,` [src]

### `impl<T> AdditiveGroup for T where
T: AbstractGroup<Additive> + AdditiveLoop + AdditiveMonoid,` [src]

### `impl<T> AdditiveGroupAbelian for T where
T: AbstractGroupAbelian<Additive> + AdditiveGroup,` [src]

### `impl<T> MultiplicativeMagma for T where
T: AbstractMagma<Multiplicative>,` [src]

### `impl<T> MultiplicativeSemigroup for T where
T: AbstractSemigroup<Multiplicative> + ClosedMul<T> + MultiplicativeMagma,` [src]

### `impl<T> MultiplicativeMonoid for T where
T: AbstractMonoid<Multiplicative> + MultiplicativeSemigroup + One,` [src]

# Help

## Keyboard Shortcuts

`?`
  Show this help dialog
`S`
  Focus the search field
`↑`
  Move up in search results
`↓`
  Move down in search results
`↹`
  Switch tab
`⏎`
  Go to active search result
`+`
  Expand all sections
`-`
  Collapse all sections

## Search Tricks

Prefix searches with a type followed by a colon (e.g., `fn:`) to restrict the search to a given type.

Accepted types are: `fn`, `mod`, `struct`, `enum`, `trait`, `type`, `macro`, and `const`.

Search functions by type signature (e.g., `vec -> usize` or `* -> vec`)

Search multiple things at once by splitting your query with comma (e.g., `str,u8` or `String,struct:Vec,test`)