Struct spectra::linear::Quaternion [] [src]

#[repr(C)]
pub struct Quaternion<S> { pub s: S, pub v: Vector3<S>, }

A quaternion in scalar/vector form.

This type is marked as #[repr(C)].

Fields

The scalar part of the quaternion.

The vector part of the quaternion.

Methods

impl<S> Quaternion<S> where
    S: BaseFloat
[src]

[src]

Construct a new quaternion from one scalar component and three imaginary components.

[src]

Construct a new quaternion from a scalar and a vector.

[src]

Construct a new quaternion as a closest arc between two vectors

Return the closest rotation that turns src vector into dst.

  • [Related StackOverflow question] (http://stackoverflow.com/questions/1171849/finding-quaternion-representing-the-rotation-from-one-vector-to-another)
  • [Ogre implementation for normalized vectors] (https://bitbucket.org/sinbad/ogre/src/9db75e3ba05c/OgreMain/include/OgreVector3.h?fileviewer=file-view-default#cl-651)

[src]

The conjugate of the quaternion.

[src]

Do a normalized linear interpolation with other, by amount.

[src]

Spherical Linear Intoperlation

Return the spherical linear interpolation between the quaternion and other. Both quaternions should be normalized first.

Performance notes

The acos operation used in slerp is an expensive operation, so unless your quarternions are far away from each other it's generally more advisable to use nlerp when you know your rotations are going to be small.

  • [Understanding Slerp, Then Not Using It] (http://number-none.com/product/Understanding%20Slerp,%20Then%20Not%20Using%20It/)
  • [Arcsynthesis OpenGL tutorial] (http://www.arcsynthesis.org/gltut/Positioning/Tut08%20Interpolation.html)

impl<S> Quaternion<S> where
    S: Copy + NumCast
[src]

[src]

Component-wise casting to another type.

Trait Implementations

impl<S> Neg for Quaternion<S> where
    S: BaseFloat
[src]

The resulting type after applying the - operator.

[src]

Performs the unary - operation.

impl<'a, S> Neg for &'a Quaternion<S> where
    S: BaseFloat
[src]

The resulting type after applying the - operator.

[src]

Performs the unary - operation.

impl<S> AddAssign<Quaternion<S>> for Quaternion<S> where
    S: BaseFloat + AddAssign<S>, 
[src]

[src]

Performs the += operation.

impl<S> ApproxEq for Quaternion<S> where
    S: BaseFloat
[src]

Used for specifying relative comparisons.

[src]

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

[src]

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

[src]

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

[src]

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

[src]

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

The inverse of ApproxEq::relative_eq.

The inverse of ApproxEq::ulps_eq.

impl<S> IndexMut<RangeFrom<usize>> for Quaternion<S> where
    S: BaseFloat
[src]

Important traits for &'a mut [u8]
[src]

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

impl<S> IndexMut<RangeTo<usize>> for Quaternion<S> where
    S: BaseFloat
[src]

Important traits for &'a mut [u8]
[src]

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

impl<S> IndexMut<Range<usize>> for Quaternion<S> where
    S: BaseFloat
[src]

Important traits for &'a mut [u8]
[src]

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

impl<S> IndexMut<usize> for Quaternion<S> where
    S: BaseFloat
[src]

Important traits for &'a mut W
[src]

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

impl<S> IndexMut<RangeFull> for Quaternion<S> where
    S: BaseFloat
[src]

Important traits for &'a mut [u8]
[src]

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

impl<S> Index<Range<usize>> for Quaternion<S> where
    S: BaseFloat
[src]

The returned type after indexing.

Important traits for &'a mut [u8]
[src]

Performs the indexing (container[index]) operation.

impl<S> Index<usize> for Quaternion<S> where
    S: BaseFloat
[src]

The returned type after indexing.

Important traits for &'a mut W
[src]

Performs the indexing (container[index]) operation.

impl<S> Index<RangeFull> for Quaternion<S> where
    S: BaseFloat
[src]

The returned type after indexing.

Important traits for &'a mut [u8]
[src]

Performs the indexing (container[index]) operation.

impl<S> Index<RangeFrom<usize>> for Quaternion<S> where
    S: BaseFloat
[src]

The returned type after indexing.

Important traits for &'a mut [u8]
[src]

Performs the indexing (container[index]) operation.

impl<S> Index<RangeTo<usize>> for Quaternion<S> where
    S: BaseFloat
[src]

The returned type after indexing.

Important traits for &'a mut [u8]
[src]

Performs the indexing (container[index]) operation.

impl<S> InnerSpace for Quaternion<S> where
    S: BaseFloat
[src]

[src]

Vector dot (or inner) product.

[src]

Returns true if the vector is perpendicular (at right angles) to the other vector. Read more

[src]

Returns the squared magnitude. Read more

[src]

The distance from the tail to the tip of the vector.

[src]

Returns the angle between two vectors in radians.

[src]

Returns a vector with the same direction, but with a magnitude of 1.

[src]

Returns a vector with the same direction and a given magnitude.

[src]

Returns the result of linearly interpolating the magnitude of the vector towards the magnitude of other by the specified amount. Read more

impl<S> Sum<Quaternion<S>> for Quaternion<S> where
    S: BaseFloat
[src]

[src]

Method which takes an iterator and generates Self from the elements by "summing up" the items. Read more

impl<'a, S> Sum<&'a Quaternion<S>> for Quaternion<S> where
    S: 'a + BaseFloat
[src]

[src]

Method which takes an iterator and generates Self from the elements by "summing up" the items. Read more

impl<S> AsRef<(S, S, S, S)> for Quaternion<S> where
    S: BaseFloat
[src]

[src]

Performs the conversion.

impl<S> AsRef<[S; 4]> for Quaternion<S> where
    S: BaseFloat
[src]

[src]

Performs the conversion.

impl<S> Copy for Quaternion<S> where
    S: Copy
[src]

impl<S> VectorSpace for Quaternion<S> where
    S: BaseFloat
[src]

The associated scalar.

impl<S> MulAssign<S> for Quaternion<S> where
    S: BaseFloat + MulAssign<S>, 
[src]

[src]

Performs the *= operation.

impl<S> PartialEq<Quaternion<S>> for Quaternion<S> where
    S: PartialEq<S>, 
[src]

[src]

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

[src]

This method tests for !=.

impl<S> SubAssign<Quaternion<S>> for Quaternion<S> where
    S: BaseFloat + SubAssign<S>, 
[src]

[src]

Performs the -= operation.

impl<S> RemAssign<S> for Quaternion<S> where
    S: BaseFloat + RemAssign<S>, 
[src]

[src]

Performs the %= operation.

impl<'a, S> Mul<Vector3<S>> for &'a Quaternion<S> where
    S: BaseFloat
[src]

The resulting type after applying the * operator.

[src]

Performs the * operation.

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

The resulting type after applying the * operator.

[src]

Performs the * operation.

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

The resulting type after applying the * operator.

[src]

Performs the * operation.

impl<'a, S> Mul<S> for &'a Quaternion<S> where
    S: BaseFloat
[src]

The resulting type after applying the * operator.

[src]

Performs the * operation.

impl<'a, 'b, S> Mul<&'a Quaternion<S>> for &'b Quaternion<S> where
    S: BaseFloat
[src]

The resulting type after applying the * operator.

[src]

Performs the * operation.

impl<'a, 'b, S> Mul<&'a Vector3<S>> for &'b Quaternion<S> where
    S: BaseFloat
[src]

The resulting type after applying the * operator.

[src]

Performs the * operation.

impl<'a, S> Mul<&'a Vector3<S>> for Quaternion<S> where
    S: BaseFloat
[src]

The resulting type after applying the * operator.

[src]

Performs the * operation.

impl<S> Mul<Quaternion<S>> for Quaternion<S> where
    S: BaseFloat
[src]

The resulting type after applying the * operator.

[src]

Performs the * operation.

impl<'a, S> Mul<&'a Quaternion<S>> for Quaternion<S> where
    S: BaseFloat
[src]

The resulting type after applying the * operator.

[src]

Performs the * operation.

impl<'a, S> Mul<Quaternion<S>> for &'a Quaternion<S> where
    S: BaseFloat
[src]

The resulting type after applying the * operator.

[src]

Performs the * operation.

impl<'a> Mul<&'a Quaternion<f32>> for f32
[src]

The resulting type after applying the * operator.

[src]

Performs the * operation.

impl<S> Mul<S> for Quaternion<S> where
    S: BaseFloat
[src]

The resulting type after applying the * operator.

[src]

Performs the * operation.

impl<S> Mul<Vector3<S>> for Quaternion<S> where
    S: BaseFloat
[src]

The resulting type after applying the * operator.

[src]

Performs the * operation.

impl<'a> Mul<&'a Quaternion<f64>> for f64
[src]

The resulting type after applying the * operator.

[src]

Performs the * operation.

impl<S> Debug for Quaternion<S> where
    S: Debug
[src]

[src]

Formats the value using the given formatter. Read more

impl<S> DivAssign<S> for Quaternion<S> where
    S: BaseFloat + DivAssign<S>, 
[src]

[src]

Performs the /= operation.

impl<S> From<Quaternion<S>> for Matrix4<S> where
    S: BaseFloat
[src]

[src]

Convert the quaternion to a 4 x 4 rotation matrix.

impl<S> From<Matrix3<S>> for Quaternion<S> where
    S: BaseFloat
[src]

[src]

Convert the matrix to a quaternion

impl<'a, S> From<&'a mut [S; 4]> for &'a mut Quaternion<S> where
    S: BaseFloat
[src]

[src]

Performs the conversion.

impl<S> From<Quaternion<S>> for Basis3<S> where
    S: BaseFloat
[src]

[src]

Performs the conversion.

impl<S> From<Quaternion<S>> for Matrix3<S> where
    S: BaseFloat
[src]

[src]

Convert the quaternion to a 3 x 3 rotation matrix.

impl<S> From<Quaternion<S>> for Euler<Rad<S>> where
    S: BaseFloat
[src]

[src]

Performs the conversion.

impl<S> From<[S; 4]> for Quaternion<S> where
    S: BaseFloat
[src]

[src]

Performs the conversion.

impl<'a, S> From<&'a (S, S, S, S)> for &'a Quaternion<S> where
    S: BaseFloat
[src]

[src]

Performs the conversion.

impl<S> From<(S, S, S, S)> for Quaternion<S> where
    S: BaseFloat
[src]

[src]

Performs the conversion.

impl<'a, S> From<&'a mut (S, S, S, S)> for &'a mut Quaternion<S> where
    S: BaseFloat
[src]

[src]

Performs the conversion.

impl<'a, S> From<&'a [S; 4]> for &'a Quaternion<S> where
    S: BaseFloat
[src]

[src]

Performs the conversion.

impl<A> From<Euler<A>> for Quaternion<<A as Angle>::Unitless> where
    A: Angle + Into<Rad<<A as Angle>::Unitless>>, 
[src]

[src]

Performs the conversion.

impl<S> From<Basis3<S>> for Quaternion<S> where
    S: BaseFloat
[src]

[src]

Performs the conversion.

impl<S> MetricSpace for Quaternion<S> where
    S: BaseFloat
[src]

The metric to be returned by the distance function.

[src]

Returns the squared distance. Read more

[src]

The distance between two values.

impl Div<Quaternion<f32>> for f32
[src]

The resulting type after applying the / operator.

[src]

Performs the / operation.

impl<'a> Div<&'a Quaternion<f64>> for f64
[src]

The resulting type after applying the / operator.

[src]

Performs the / operation.

impl<S> Div<S> for Quaternion<S> where
    S: BaseFloat
[src]

The resulting type after applying the / operator.

[src]

Performs the / operation.

impl Div<Quaternion<f64>> for f64
[src]

The resulting type after applying the / operator.

[src]

Performs the / operation.

impl<'a, S> Div<S> for &'a Quaternion<S> where
    S: BaseFloat
[src]

The resulting type after applying the / operator.

[src]

Performs the / operation.

impl<'a> Div<&'a Quaternion<f32>> for f32
[src]

The resulting type after applying the / operator.

[src]

Performs the / operation.

impl<S> Rand for Quaternion<S> where
    S: BaseFloat + Rand
[src]

[src]

Generates a random instance of this type using the specified source of randomness. Read more

impl<'a, S> Add<&'a Quaternion<S>> for Quaternion<S> where
    S: BaseFloat
[src]

The resulting type after applying the + operator.

[src]

Performs the + operation.

impl<'a, S> Add<Quaternion<S>> for &'a Quaternion<S> where
    S: BaseFloat
[src]

The resulting type after applying the + operator.

[src]

Performs the + operation.

impl<'a, 'b, S> Add<&'a Quaternion<S>> for &'b Quaternion<S> where
    S: BaseFloat
[src]

The resulting type after applying the + operator.

[src]

Performs the + operation.

impl<S> Add<Quaternion<S>> for Quaternion<S> where
    S: BaseFloat
[src]

The resulting type after applying the + operator.

[src]

Performs the + operation.

impl<S> Clone for Quaternion<S> where
    S: Clone
[src]

[src]

Returns a copy of the value. Read more

1.0.0
[src]

Performs copy-assignment from source. Read more

impl<S> Rotation<Point3<S>> for Quaternion<S> where
    S: BaseFloat
[src]

[src]

Create a rotation to a given direction with an 'up' vector.

[src]

Create a shortest rotation to transform vector 'a' into 'b'. Both given vectors are assumed to have unit length. Read more

[src]

Rotate a vector using this rotation.

[src]

Create a new rotation which "un-does" this rotation. That is, r * r.invert() is the identity. Read more

[src]

Rotate a point using this rotation, by converting it to its representation as a vector. Read more

impl<S> One for Quaternion<S> where
    S: BaseFloat
[src]

[src]

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

[src]

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

impl<'a, S> Sub<Quaternion<S>> for &'a Quaternion<S> where
    S: BaseFloat
[src]

The resulting type after applying the - operator.

[src]

Performs the - operation.

impl<'a, 'b, S> Sub<&'a Quaternion<S>> for &'b Quaternion<S> where
    S: BaseFloat
[src]

The resulting type after applying the - operator.

[src]

Performs the - operation.

impl<'a, S> Sub<&'a Quaternion<S>> for Quaternion<S> where
    S: BaseFloat
[src]

The resulting type after applying the - operator.

[src]

Performs the - operation.

impl<S> Sub<Quaternion<S>> for Quaternion<S> where
    S: BaseFloat
[src]

The resulting type after applying the - operator.

[src]

Performs the - operation.

impl<S> Zero for Quaternion<S> where
    S: BaseFloat
[src]

[src]

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

[src]

Returns true if self is equal to the additive identity.

impl<S> Into<[S; 4]> for Quaternion<S> where
    S: BaseFloat
[src]

[src]

Performs the conversion.

impl<S> Into<(S, S, S, S)> for Quaternion<S> where
    S: BaseFloat
[src]

[src]

Performs the conversion.

impl<'a, S> Rem<S> for &'a Quaternion<S> where
    S: BaseFloat
[src]

The resulting type after applying the % operator.

[src]

Performs the % operation.

impl<S> Rem<S> for Quaternion<S> where
    S: BaseFloat
[src]

The resulting type after applying the % operator.

[src]

Performs the % operation.

impl<'a, S> Product<&'a Quaternion<S>> for Quaternion<S> where
    S: 'a + BaseFloat
[src]

[src]

Method which takes an iterator and generates Self from the elements by multiplying the items. Read more

impl<S> Product<Quaternion<S>> for Quaternion<S> where
    S: BaseFloat
[src]

[src]

Method which takes an iterator and generates Self from the elements by multiplying the items. Read more

impl<S> AsMut<(S, S, S, S)> for Quaternion<S> where
    S: BaseFloat
[src]

[src]

Performs the conversion.

impl<S> AsMut<[S; 4]> for Quaternion<S> where
    S: BaseFloat
[src]

[src]

Performs the conversion.

impl<S> Rotation3<S> for Quaternion<S> where
    S: BaseFloat
[src]

[src]

Create a rotation using an angle around a given axis. Read more

[src]

Create a rotation from an angle around the x axis (pitch).

[src]

Create a rotation from an angle around the y axis (yaw).

[src]

Create a rotation from an angle around the z axis (roll).

Auto Trait Implementations

impl<S> Send for Quaternion<S> where
    S: Send

impl<S> Sync for Quaternion<S> where
    S: Sync