This class represents a quaternion. More...
#include "Quaternion.hpp"
Public Member Functions | |
QuaternionT (T x_=0, T y_=0, T z_=0, T w_=1) | |
The default constructor. It initializes the quaternion from the given x_, y_, z_ and w_ respectively. More... | |
template<class C > | |
QuaternionT (const C Values[]) | |
Constructs a quaternion from an array of (at least) four values. More... | |
QuaternionT (const AnglesT< T > &Angles) | |
Constructs a quaternion from the given angles. More... | |
QuaternionT (const Matrix3x3T< T > &Mat) | |
Constructs a quaternion from the given rotation matrix. More... | |
QuaternionT (const Vector3T< T > &Axis, const T Angle) | |
Constructs a quaternion from a rotation axis and angle. More... | |
Vector3T< T > | GetXYZ () const |
Returns the x, y and z components as a Vector3T<T>. More... | |
QuaternionT< T > | GetConjugate () const |
Returns the conjugate of this quaternion. More... | |
T | dot (const QuaternionT< T > &B) const |
Returns the dot product of this quaternion and B. More... | |
T | length () const |
Returns the length of this quaternion. More... | |
T | lengthSqr () const |
Returns the square of the length of this quaternion. More... | |
bool | IsNormal (const T Epsilon=0) const |
Returns if this quaternion is normal, i.e. More... | |
T & | operator[] (unsigned int Index) |
Component access by index number (0 to 3) rather than by name. More... | |
const T & | operator[] (unsigned int Index) const |
Component access by index number (0 to 3) rather than by name. More... | |
bool | operator== (const QuaternionT< T > &B) const |
Returns whether this quaternion and B are (bit-wise) identical. More... | |
bool | operator!= (const QuaternionT< T > &B) const |
Returns whether this quaternion and B are not equal (bit-wise). More... | |
QuaternionT< T > | operator- () const |
The unary minus operator. More... | |
QuaternionT< T > | operator+ (const QuaternionT< T > &B) const |
Returns the sum of this quaternion and B. More... | |
QuaternionT< T > & | operator+= (const QuaternionT< T > &B) |
Adds B to this quaternion. More... | |
QuaternionT< T > | operator- (const QuaternionT< T > &B) const |
Returns the difference between this quaternion and B. More... | |
QuaternionT< T > & | operator-= (const QuaternionT< T > &B) |
Subtracts B from this quaternion. More... | |
QuaternionT< T > | operator* (const QuaternionT< T > &B) const |
Returns the quaternion Q that expresses the combined rotation of this quaternion and B , Q = this*B . More... | |
QuaternionT< T > | operator* (const T s) const |
Returns a copy of this quaternion scaled by s. More... | |
QuaternionT< T > & | operator*= (const T s) |
Scales this quaternion by s. More... | |
QuaternionT< T > | operator/ (const T s) const |
Returns a copy of this quaternion divided by s, assuming that s is not 0. More... | |
QuaternionT< T > & | operator/= (const T s) |
Divides this quaternion by s, assuming that s is not 0. More... | |
Static Public Member Functions | |
static QuaternionT | FromXYZ (const Vector3T< T > &Vec) |
Constructs a quaternion from the first three components (x, y, z) of a unit quaternion. More... | |
static QuaternionT | Euler (const T Pitch, const T Yaw, const T Roll) |
Constructs a quaternion from three Euler angles. More... | |
Public Attributes | |
T | x |
T | y |
T | z |
T | w |
This class represents a quaternion.
|
inline |
The default constructor. It initializes the quaternion from the given x_, y_, z_ and w_ respectively.
|
inlineexplicit |
Constructs a quaternion from an array of (at least) four values.
QuaternionT::QuaternionT | ( | const AnglesT< T > & | Angles | ) |
Constructs a quaternion from the given angles.
See the documentation of the AnglesT class for details.
QuaternionT::QuaternionT | ( | const Matrix3x3T< T > & | Mat | ) |
Constructs a quaternion from the given rotation matrix.
If the matrix is not orthonormal, the result is undefined.
QuaternionT::QuaternionT | ( | const Vector3T< T > & | Axis, |
const T | Angle | ||
) |
Constructs a quaternion from a rotation axis and angle.
This is useful, for example, to rotate one vector onto another, as is done in the implementation of cf::GameSys::ComponentTransformT::LookAt().
Axis | The axis to rotate about. This given axis must be of unit length, or else the result is undefined. |
Angle | The angle to rotate about, in radians. |
|
inline |
Returns the dot product of this quaternion and B.
|
static |
Constructs a quaternion from three Euler angles.
Pitch | the Euler rotation about the x-axis, in radians. |
Yaw | the Euler rotation about the y-axis, in radians. |
Roll | the Euler rotation about the z-axis, in radians. Note that the assignment of angles to axes assumes a right-handed coordinate system where the z-axis points towards the viewer. This is especially different from the coordinate system that class cf::math::AnglesT<T> uses, which is also right-handed, but rotated by 90 degrees so that the z-axis points up and the y-axis away from the viewer! |
|
inlinestatic |
Constructs a quaternion from the first three components (x, y, z) of a unit quaternion.
|
inline |
Returns the conjugate of this quaternion.
If the quaternion is of unit length, then the conjugate is also its inverse.
|
inline |
Returns the x, y and z components as a Vector3T<T>.
|
inline |
Returns if this quaternion is normal, i.e.
has length 1 within the given tolerance.
Epsilon | The tolerance value. |
|
inline |
Returns the length of this quaternion.
|
inline |
Returns the square of the length of this quaternion.
|
inline |
Returns whether this quaternion and B are not equal (bit-wise).
Use this operator with care, as it comes without any epsilon threshold to take rounding errors into account.
B | Quaternion to compare to. |
|
inline |
Returns the quaternion Q that expresses the combined rotation of this quaternion and B
, Q = this*B
.
|
inline |
Returns a copy of this quaternion scaled by s.
|
inline |
Scales this quaternion by s.
|
inline |
Returns the sum of this quaternion and B.
|
inline |
Adds B to this quaternion.
|
inline |
The unary minus operator.
|
inline |
Returns the difference between this quaternion and B.
|
inline |
Subtracts B from this quaternion.
|
inline |
Returns a copy of this quaternion divided by s, assuming that s is not 0.
|
inline |
Divides this quaternion by s, assuming that s is not 0.
|
inline |
Returns whether this quaternion and B are (bit-wise) identical.
Use this operator with care, as it comes without any epsilon threshold to take rounding errors into account.
B | Quaternion to compare to. |
|
inline |
Component access by index number (0 to 3) rather than by name.
Index | Index of the component to access. Can only be 0, 1, 2 or 3 (for x, y, z, w). |
InvalidOperationE | if Index is not 0, 1, 2 or 3. |
|
inline |
Component access by index number (0 to 3) rather than by name.
Index | Index of the component to access. Can only be 0, 1, 2 or 3 (for x, y, z, w). |
InvalidOperationE | if Index is not 0, 1, 2 or 3. |