A quaternion struct primarily for rotation representations and calculations. More...
Public Member Functions | |
Quaternion () | |
Creates an uninitialized quaternion. More... | |
Quaternion (int i) | |
Creates a quaternion initialized to zero rotation. More... | |
template<class S > | |
Quaternion (S s, S vi, S vj, S vk) | |
Creates a quaternion from the specified real and imaginary parts. More... | |
template<class S , class T2 , class M2 > | |
Quaternion (S s, const Vector3< T2, M2 > &v) | |
Creates a quaternion from the specified real and imaginary parts. More... | |
template<class S , class T2 , class M2 > | |
Quaternion (const Vector3< T2, M2 > &v, S s) | |
Creates a quaternion from the specified real and imaginary parts. More... | |
template<class T2 , class M2 > | |
Quaternion (const Quaternion< T2, M2 > &q) | |
Copies a quaternion. More... | |
template<class T2 , class M2 > | |
Quaternion (const Rotation< T2, M2 > &r) | |
Cast from rotation. More... | |
template<class T2 , class M2 > | |
Quaternion (const Vector3< T2, M2 > &v) | |
Casting from vector to quaternion. More... | |
template<class T2 , class M2 > | |
Quaternion (const Matrix3< T2, M2 > &m) | |
Casting from matrix. More... | |
Quaternion< T, M > & | operator= (const Quaternion< T, M > &o) |
Copy operator. More... | |
template<class T2 , class M2 > | |
Quaternion< T, M > & | operator= (const Quaternion< T2, M2 > &o) |
Copy operator. More... | |
Quaternion< T, M > | operator- () const |
Negating quaternion. More... | |
Quaternion< T, M > | slerp (const Quaternion< T, M > &q, double t) |
Spherical linear interpolation between this and the provided quaternion. More... | |
Quaternion< T, M > | slerp (double t) |
Spherical linear interpolation from zero rotation to this. More... | |
template<class T2 , class M2 > | |
Vector3< T, M > | rotate (const Vector3< T2, M2 > &v) const |
Rotate a vector using this quaternion. More... | |
template<class T2 , class M2 > | |
Vector4< T, M > | rotate (const Vector4< T2, M2 > &v) const |
Rotate a vector using this quaternion. More... | |
Quaternion< T, M > | conjugate () const |
Returns the quaternion conjugate. More... | |
Quaternion< T, M > | inverse () const |
Returns the quaternion inverse. More... | |
T | norm () const |
Returns the norm of this quaternion. More... | |
Quaternion< T, M > | unit () const |
Return a unit version of this quaternion. More... | |
Static Public Member Functions | |
template<class S , class T2 , class M2 > | |
static Quaternion< T, M > | fromAxisAngle (const Vector3< T2, M2 > &v, S a) |
Creates a quaternion from an axis and an angle of rotation around this axis. More... | |
template<class T2 , class M2 , class T3 , class M3 > | |
static Quaternion< T, M > | fromVectorPair (const Vector3< T2, M2 > &x, const Vector3< T3, M3 > &y) |
Create the quaternion that would rotate a specified unit vector to the other specified unit vector. More... | |
template<class T2 , class M2 , class T3 , class M3 , class T4 , class M4 , class T5 , class M5 > | |
static Quaternion< T, M > | fromAnglePair (const Vector3< T2, M2 > &x0, const Vector3< T3, M3 > &y0, const Vector3< T4, M4 > &x1, const Vector3< T5, M5 > &y1) |
Create the quaternion that would rotate a specified angle of unit vectors into the other specified angle of unit vectors. More... | |
template<class T2 , class M2 > | |
static Quaternion< T, M > | fromEulerAngles (Vector3< T2, M2 > &v) |
Create a quaternion from Euler angles. More... | |
Public Attributes | |
T | s |
The real part of the quaternion. More... | |
Vector3< T, M > | v |
The imaginary part of the quaternion. More... | |
A quaternion struct primarily for rotation representations and calculations.
This implementation, however, can also be used for real four dimensional complex calculations. All operators are correctly implemented, so take care. The inverse and negation does not always give the result people think they should.
|
inline |
Creates an uninitialized quaternion.
|
inlineexplicit |
Creates a quaternion initialized to zero rotation.
Observe that this is not the same as a zero quaternion.
|
inline |
Creates a quaternion from the specified real and imaginary parts.
|
inline |
Creates a quaternion from the specified real and imaginary parts.
|
inline |
Creates a quaternion from the specified real and imaginary parts.
|
inline |
Copies a quaternion.
References a3d::Quaternion< T, M >::s, and a3d::Quaternion< T, M >::v.
|
inlineexplicit |
Cast from rotation.
References a3d::Rotation< T, M >::a, a3d::Quaternion< T, M >::s, a3d::Rotation< T, M >::v, and a3d::Quaternion< T, M >::v.
|
inlineexplicit |
Casting from vector to quaternion.
The vector becomes the complex part of the quaternion
|
inlineexplicit |
Casting from matrix.
References a3d::Quaternion< T, M >::s, and a3d::Quaternion< T, M >::v.
|
inline |
Returns the quaternion conjugate.
References a3d::Quaternion< T, M >::s, and a3d::Quaternion< T, M >::v.
Referenced by a3d::Quaternion< T, M >::fromAnglePair(), a3d::Quaternion< T, M >::inverse(), a3d::Quaternion< T, M >::norm(), and a3d::Quaternion< T, M >::rotate().
|
inlinestatic |
Create the quaternion that would rotate a specified angle of unit vectors into the other specified angle of unit vectors.
The result is unspecified if either vector is not of unit length or if the angle between the vector pairs differs.
x0 | the first unit vector in the initial angle |
x1 | the second unit vector in the initial angle |
y0 | the first unit vector in the rotated angle |
y1 | the second unit vector in the rotated angle |
References a3d::Quaternion< T, M >::conjugate(), a3d::Quaternion< T, M >::fromVectorPair(), and a3d::Vector3< T, M >::normalized().
|
inlinestatic |
Creates a quaternion from an axis and an angle of rotation around this axis.
The axis of rotation must be of unit length.
References a3d::Quaternion< T, M >::v.
|
inlinestatic |
Create a quaternion from Euler angles.
|
inlinestatic |
Create the quaternion that would rotate a specified unit vector to the other specified unit vector.
The result is unspecified if either vector is not of unit length.
x | the initial unit vector |
y | the rotated unit vector |
References a3d::Vector3< T, M >::length().
Referenced by a3d::Quaternion< T, M >::fromAnglePair().
|
inline |
Returns the quaternion inverse.
If the quaternion is unit the result is equal to the conjugate, but this function is slightly slower than using the conjugate directly.
References A3D_WARNING_EXPENSIVE, a3d::Quaternion< T, M >::conjugate(), and a3d::Quaternion< T, M >::s.
Referenced by a3d::operator/().
|
inline |
Returns the norm of this quaternion.
References a3d::Quaternion< T, M >::conjugate(), and a3d::Quaternion< T, M >::s.
Referenced by a3d::Quaternion< T, M >::unit().
|
inline |
Negating quaternion.
Both real and imaginary parts are negated.
References a3d::Quaternion< T, M >::s, and a3d::Quaternion< T, M >::v.
|
inline |
Copy operator.
References a3d::Quaternion< T, M >::s, and a3d::Quaternion< T, M >::v.
|
inline |
Copy operator.
References a3d::Quaternion< T, M >::s, and a3d::Quaternion< T, M >::v.
|
inline |
Rotate a vector using this quaternion.
For this to be correct the quaternion must be unit, which is usually true if only rotational operations have previously been performed.
References a3d::Quaternion< T, M >::conjugate().
|
inline |
Rotate a vector using this quaternion.
For this to be correct the quaternion must be unit, which is usually true if only rotational operations have previously been performed.
References a3d::Quaternion< T, M >::conjugate(), and a3d::Quaternion< T, M >::v.
|
inline |
Spherical linear interpolation between this and the provided quaternion.
The interpolation is specified through the t parameter in the interval [0,1].
References a3d::Quaternion< T, M >::s, and a3d::Quaternion< T, M >::v.
Referenced by a3d::Quaternion< T, M >::slerp().
|
inline |
Spherical linear interpolation from zero rotation to this.
Use this function to scale the rotation defined by this quaternion. Using multiplication with a scalar value will not scale the rotation but the complex number.
References a3d::Quaternion< T, M >::slerp().
|
inline |
Return a unit version of this quaternion.
References a3d::Quaternion< T, M >::norm(), a3d::Quaternion< T, M >::s, and a3d::Quaternion< T, M >::v.
T a3d::Quaternion< T, M >::s |
The real part of the quaternion.
Referenced by a3d::Quaternion< T, M >::conjugate(), a3d::Quaternion< T, M >::inverse(), a3d::Matrix3< T, M >::Matrix3(), a3d::Matrix4< T, M >::Matrix4(), a3d::Quaternion< T, M >::norm(), a3d::operator*(), a3d::operator+(), a3d::Quaternion< T, M >::operator-(), a3d::operator-(), a3d::Quaternion< T, M >::operator=(), a3d::Quaternion< T, M >::Quaternion(), a3d::Quaternion< T, M >::slerp(), and a3d::Quaternion< T, M >::unit().
Vector3<T,M> a3d::Quaternion< T, M >::v |
The imaginary part of the quaternion.
Referenced by a3d::Quaternion< T, M >::conjugate(), a3d::Quaternion< T, M >::fromAxisAngle(), a3d::Matrix3< T, M >::Matrix3(), a3d::Matrix4< T, M >::Matrix4(), a3d::operator*(), a3d::operator+(), a3d::Quaternion< T, M >::operator-(), a3d::operator-(), a3d::Quaternion< T, M >::operator=(), a3d::Quaternion< T, M >::Quaternion(), a3d::Quaternion< T, M >::rotate(), a3d::Rotation< T, M >::Rotation(), a3d::Quaternion< T, M >::slerp(), and a3d::Quaternion< T, M >::unit().