pub struct Quaternion<S> {
    pub v: Vector3<S>,
    pub s: S,
}
Expand description

A quaternion in scalar/vector form.

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

Fields§

§v: Vector3<S>

The vector part of the quaternion.

§s: S

The scalar part of the quaternion.

Implementations§

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

Construct a new quaternion from a scalar and a vector.

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)

The conjugate of the quaternion.

Do a normalized linear interpolation with other, by amount.

This takes the shortest path, so if the quaternions have a negative dot product, the interpolation will be between self and -other.

Spherical Linear Interpolation

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

This takes the shortest path, so if the quaternions have a negative dot product, the interpolation will be between self and -other.

Performance notes

The acos operation used in slerp is an expensive operation, so unless your quaternions 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)

Component-wise casting to another type.

Trait Implementations§

Used for specifying relative comparisons.
The default tolerance to use when testing values that are close together. Read more
A test for equality that uses the absolute difference to compute the approximate equality of two numbers.
The inverse of AbsDiffEq::abs_diff_eq.
The resulting type after applying the + operator.
Performs the + operation. Read more
The resulting type after applying the + operator.
Performs the + operation. Read more
The resulting type after applying the + operator.
Performs the + operation. Read more
The resulting type after applying the + operator.
Performs the + operation. Read more
Performs the += operation. Read more
Converts this type into a mutable reference of the (usually inferred) input type.
Converts this type into a mutable reference of the (usually inferred) input type.
Converts this type into a shared reference of the (usually inferred) input type.
Converts this type into a shared reference of the (usually inferred) input type.
Returns a copy of the value. Read more
Performs copy-assignment from source. Read more
Formats the value using the given formatter. Read more
Deserialize this value from the given Serde deserializer. Read more
The resulting type after applying the / operator.
Performs the / operation. Read more
The resulting type after applying the / operator.
Performs the / operation. Read more
Performs the /= operation. Read more
Converts to this type from the input type.
Converts to this type from the input type.
Converts to this type from the input type.
Converts to this type from the input type.
Converts to this type from the input type.
Converts to this type from the input type.
Converts to this type from the input type.
Converts to this type from the input type.

Convert the matrix to a quaternion

Converts to this type from the input type.
Converts to this type from the input type.

Convert the quaternion to a 3 x 3 rotation matrix.

Convert the quaternion to a 4 x 4 rotation matrix.

The returned type after indexing.
Performs the indexing (container[index]) operation. Read more
The returned type after indexing.
Performs the indexing (container[index]) operation. Read more
The returned type after indexing.
Performs the indexing (container[index]) operation. Read more
The returned type after indexing.
Performs the indexing (container[index]) operation. Read more
The returned type after indexing.
Performs the indexing (container[index]) operation. Read more
Performs the mutable indexing (container[index]) operation. Read more
Performs the mutable indexing (container[index]) operation. Read more
Performs the mutable indexing (container[index]) operation. Read more
Performs the mutable indexing (container[index]) operation. Read more
Performs the mutable indexing (container[index]) operation. Read more
Vector dot (or inner) product.
Returns the squared magnitude. Read more
Returns the angle between two vectors in radians.
Returns the vector projection of the current inner space projected onto the supplied argument.
Converts this type into the (usually inferred) input type.
Converts this type into the (usually inferred) input type.
The metric to be returned by the distance function.
Returns the squared distance. Read more
The resulting type after applying the * operator.
Performs the * operation. Read more
The resulting type after applying the * operator.
Performs the * operation. Read more
The resulting type after applying the * operator.
Performs the * operation. Read more
The resulting type after applying the * operator.
Performs the * operation. Read more
The resulting type after applying the * operator.
Performs the * operation. Read more
The resulting type after applying the * operator.
Performs the * operation. Read more
The resulting type after applying the * operator.
Performs the * operation. Read more
The resulting type after applying the * operator.
Performs the * operation. Read more
The resulting type after applying the * operator.
Performs the * operation. Read more
The resulting type after applying the * operator.
Performs the * operation. Read more
Performs the *= operation. Read more
The resulting type after applying the - operator.
Performs the unary - operation. Read more
The resulting type after applying the - operator.
Performs the unary - operation. Read more
Returns the multiplicative identity element of Self, 1. Read more
Sets self to the multiplicative identity element of Self, 1.
Returns true if self is equal to the multiplicative identity. Read more
This method tests for self and other values to be equal, and is used by ==.
This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Method which takes an iterator and generates Self from the elements by multiplying the items.
Method which takes an iterator and generates Self from the elements by multiplying the items.
The default relative tolerance for testing values that are far-apart. Read more
A test for equality that uses a relative comparison if the values are far apart.
The inverse of RelativeEq::relative_eq.
The resulting type after applying the % operator.
Performs the % operation. Read more
The resulting type after applying the % operator.
Performs the % operation. Read more
Performs the %= operation. Read more

Evaluate the conjugation of vec by self.

Note that self should be a unit quaternion (i.e. normalized) to represent a 3D rotation.

Create a rotation to a given direction with an ‘up’ vector.
Create a shortest rotation to transform vector ‘a’ into ‘b’. Both given vectors are assumed to have unit length.
Create a new rotation which “un-does” this rotation. That is, r * r.invert() is the identity.
Rotate a point using this rotation, by converting it to its representation as a vector.
Create a rotation using an angle around a given axis. Read more
Create a rotation from an angle around the x axis (pitch).
Create a rotation from an angle around the y axis (yaw).
Create a rotation from an angle around the z axis (roll).
Serialize this value into the given Serde serializer. Read more
The resulting type after applying the - operator.
Performs the - operation. Read more
The resulting type after applying the - operator.
Performs the - operation. Read more
The resulting type after applying the - operator.
Performs the - operation. Read more
The resulting type after applying the - operator.
Performs the - operation. Read more
Performs the -= operation. Read more
Method which takes an iterator and generates Self from the elements by “summing up” the items.
Method which takes an iterator and generates Self from the elements by “summing up” the items.
The default ULPs to tolerate when testing values that are far-apart. Read more
A test for equality that uses units in the last place (ULP) if the values are far apart.
The inverse of UlpsEq::ulps_eq.
The associated scalar.
Returns the result of linearly interpolating the vector towards other by the specified amount.
Returns the additive identity element of Self, 0. Read more
Returns true if self is equal to the additive identity.
Sets self to the additive identity element of Self, 0.

Auto Trait Implementations§

Blanket Implementations§

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

near origin
near origin in square order
The resulting type after obtaining ownership.
Creates owned data from borrowed data, usually by cloning. Read more
Uses borrowed data to replace owned data, usually by cloning. Read more
The “distance” is less than TOLERANCE.
The “distance” is less than TOLERANCR2.
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.