Struct cgmath::Quaternion [−][src]
#[repr(C)]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
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. Read more
The inverse of AbsDiffEq::abs_diff_eq
.
type Output = Quaternion<S>
type Output = Quaternion<S>
The resulting type after applying the +
operator.
Performs the +
operation. Read more
type Output = Quaternion<S>
type Output = Quaternion<S>
The resulting type after applying the +
operator.
Performs the +
operation. Read more
type Output = Quaternion<S>
type Output = Quaternion<S>
The resulting type after applying the +
operator.
Performs the +
operation. Read more
type Output = Quaternion<S>
type Output = Quaternion<S>
The resulting type after applying the +
operator.
Performs the +
operation. Read more
Performs the +=
operation. Read more
type Output = Quaternion<f32>
type Output = Quaternion<f32>
The resulting type after applying the /
operator.
Performs the /
operation. Read more
type Output = Quaternion<f64>
type Output = Quaternion<f64>
The resulting type after applying the /
operator.
Performs the /
operation. Read more
type Output = Quaternion<f32>
type Output = Quaternion<f32>
The resulting type after applying the /
operator.
Performs the /
operation. Read more
type Output = Quaternion<f64>
type Output = Quaternion<f64>
The resulting type after applying the /
operator.
Performs the /
operation. Read more
type Output = Quaternion<S>
type Output = Quaternion<S>
The resulting type after applying the /
operator.
Performs the /
operation. Read more
type Output = Quaternion<S>
type Output = Quaternion<S>
The resulting type after applying the /
operator.
Performs the /
operation. Read more
Performs the /=
operation. Read more
Performs the conversion.
Performs the conversion.
Performs the conversion.
Performs the conversion.
Performs the conversion.
Performs the conversion.
Performs the conversion.
Performs the conversion.
Convert the matrix to a quaternion
Convert the quaternion to a 3 x 3 rotation matrix.
Convert the quaternion to a 4 x 4 rotation matrix.
Performs the conversion.
Performs the conversion.
Vector dot (or inner) product.
Returns true
if the vector is perpendicular (at right angles) to the
other vector. Read more
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. Read more
The distance from the tail to the tip of the vector.
Returns a vector with the same direction, but with a magnitude of 1
.
Returns a vector with the same direction and a given magnitude.
type Output = Quaternion<S>
type Output = Quaternion<S>
The resulting type after applying the *
operator.
Performs the *
operation. Read more
type Output = Quaternion<S>
type Output = Quaternion<S>
The resulting type after applying the *
operator.
Performs the *
operation. Read more
type Output = Quaternion<f32>
type Output = Quaternion<f32>
The resulting type after applying the *
operator.
Performs the *
operation. Read more
type Output = Quaternion<f64>
type Output = Quaternion<f64>
The resulting type after applying the *
operator.
Performs the *
operation. Read more
type Output = Quaternion<S>
type Output = Quaternion<S>
The resulting type after applying the *
operator.
Performs the *
operation. Read more
type Output = Quaternion<S>
type Output = Quaternion<S>
The resulting type after applying the *
operator.
Performs the *
operation. Read more
type Output = Quaternion<f32>
type Output = Quaternion<f32>
The resulting type after applying the *
operator.
Performs the *
operation. Read more
type Output = Quaternion<f64>
type Output = Quaternion<f64>
The resulting type after applying the *
operator.
Performs the *
operation. Read more
type Output = Quaternion<S>
type Output = Quaternion<S>
The resulting type after applying the *
operator.
Performs the *
operation. Read more
type Output = Quaternion<S>
type Output = Quaternion<S>
The resulting type after applying the *
operator.
Performs the *
operation. Read more
Performs the *=
operation. Read more
type Output = Quaternion<S>
type Output = Quaternion<S>
The resulting type after applying the -
operator.
Performs the unary -
operation. Read more
type Output = Quaternion<S>
type Output = Quaternion<S>
The resulting type after applying the -
operator.
Performs the unary -
operation. Read more
Returns the multiplicative identity element of Self
, 1
. Read more
This method tests for self
and other
values to be equal, and is used
by ==
. Read more
This method tests for !=
.
Method which takes an iterator and generates Self
from the elements by
multiplying the items. Read more
Method which takes an iterator and generates Self
from the elements by
multiplying the items. Read more
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
.
type Output = Quaternion<S>
type Output = Quaternion<S>
The resulting type after applying the %
operator.
Performs the %
operation. Read more
type Output = Quaternion<S>
type Output = Quaternion<S>
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. Read more
Create a new rotation which “un-does” this rotation. That is,
r * r.invert()
is the identity. Read more
Rotate a point using this rotation, by converting it to its representation as a vector. Read more
type Output = Quaternion<S>
type Output = Quaternion<S>
The resulting type after applying the -
operator.
Performs the -
operation. Read more
type Output = Quaternion<S>
type Output = Quaternion<S>
The resulting type after applying the -
operator.
Performs the -
operation. Read more
type Output = Quaternion<S>
type Output = Quaternion<S>
The resulting type after applying the -
operator.
Performs the -
operation. Read more
type Output = Quaternion<S>
type Output = Quaternion<S>
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. Read more
Method which takes an iterator and generates Self
from the elements by
“summing up” the items. Read more
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.
Auto Trait Implementations
impl<S> RefUnwindSafe for Quaternion<S> where
S: RefUnwindSafe,
impl<S> Send for Quaternion<S> where
S: Send,
impl<S> Sync for Quaternion<S> where
S: Sync,
impl<S> Unpin for Quaternion<S> where
S: Unpin,
impl<S> UnwindSafe for Quaternion<S> where
S: UnwindSafe,
Blanket Implementations
Mutably borrows from an owned value. Read more