Quaternion class for representing rotations. More...
#include <quaternion.h>
Public Member Functions | |
quaternion () | |
Default Constructor. More... | |
quaternion (f32 x, f32 y, f32 z, f32 w) | |
Constructor. More... | |
quaternion (f32 x, f32 y, f32 z) | |
Constructor which converts euler angles (radians) to a quaternion. More... | |
quaternion (const vector3df &vec) | |
Constructor which converts euler angles (radians) to a quaternion. More... | |
quaternion (const matrix4 &mat) | |
Constructor which converts a matrix to a quaternion. More... | |
f32 | dotProduct (const quaternion &other) const |
Calculates the dot product. More... | |
bool | equals (const quaternion &other, const f32 tolerance=ROUNDING_ERROR_f32) const |
returns if this quaternion equals the other one, taking floating point rounding errors into account More... | |
quaternion & | fromAngleAxis (f32 angle, const vector3df &axis) |
Create quaternion from rotation angle and rotation axis. More... | |
matrix4 | getMatrix () const |
Creates a matrix from this quaternion. More... | |
void | getMatrix (matrix4 &dest, const core::vector3df &translation=core::vector3df()) const |
Creates a matrix from this quaternion. More... | |
void | getMatrix_transposed (matrix4 &dest) const |
Creates a matrix from this quaternion. More... | |
void | getMatrixCenter (matrix4 &dest, const core::vector3df ¢er, const core::vector3df &translation) const |
quaternion & | lerp (quaternion q1, quaternion q2, f32 time) |
Set this quaternion to the linear interpolation between two quaternions. More... | |
quaternion & | makeIdentity () |
Set quaternion to identity. More... | |
quaternion & | makeInverse () |
Inverts this quaternion. More... | |
quaternion & | normalize () |
Normalizes the quaternion. More... | |
bool | operator!= (const quaternion &other) const |
inequality operator More... | |
quaternion | operator* (const quaternion &other) const |
Multiplication operator. More... | |
quaternion | operator* (f32 s) const |
Multiplication operator with scalar. More... | |
vector3df | operator* (const vector3df &v) const |
Multiplication operator. More... | |
quaternion & | operator*= (f32 s) |
Multiplication operator with scalar. More... | |
quaternion & | operator*= (const quaternion &other) |
Multiplication operator. More... | |
quaternion | operator+ (const quaternion &other) const |
Add operator. More... | |
quaternion & | operator= (const quaternion &other) |
Assignment operator. More... | |
quaternion & | operator= (const matrix4 &other) |
Matrix assignment operator. More... | |
bool | operator== (const quaternion &other) const |
Equalilty operator. More... | |
quaternion & | rotationFromTo (const vector3df &from, const vector3df &to) |
Set quaternion to represent a rotation from one vector to another. More... | |
quaternion & | set (f32 x, f32 y, f32 z, f32 w) |
Sets new quaternion. More... | |
quaternion & | set (f32 x, f32 y, f32 z) |
Sets new quaternion based on euler angles (radians) More... | |
quaternion & | set (const core::vector3df &vec) |
Sets new quaternion based on euler angles (radians) More... | |
quaternion & | set (const core::quaternion &quat) |
Sets new quaternion from other quaternion. More... | |
quaternion & | slerp (quaternion q1, quaternion q2, f32 time, f32 threshold=.05f) |
Set this quaternion to the result of the spherical interpolation between two quaternions. More... | |
void | toAngleAxis (f32 &angle, core::vector3df &axis) const |
Fills an angle (radians) around an axis (unit vector) More... | |
void | toEuler (vector3df &euler) const |
Output this quaternion to an euler angle (radians) More... | |
Public Attributes | |
f32 | W |
f32 | X |
Quaternion elements. More... | |
f32 | Y |
f32 | Z |
Quaternion class for representing rotations.
It provides cheap combinations and avoids gimbal locks. Also useful for interpolations.
Definition at line 26 of file quaternion.h.
|
inline |
Default Constructor.
Definition at line 31 of file quaternion.h.
Referenced by operator*(), operator+(), and quaternion().
Constructor.
Definition at line 34 of file quaternion.h.
References dotProduct(), equals(), fromAngleAxis(), getMatrix(), getMatrix_transposed(), getMatrixCenter(), lerp(), makeIdentity(), makeInverse(), normalize(), operator!=(), operator*(), operator*=(), operator+(), operator=(), operator==(), quaternion(), rotationFromTo(), irr::core::ROUNDING_ERROR_f32, slerp(), toAngleAxis(), and toEuler().
Constructor which converts euler angles (radians) to a quaternion.
Definition at line 187 of file quaternion.h.
|
inline |
Constructor which converts euler angles (radians) to a quaternion.
Definition at line 194 of file quaternion.h.
References irr::core::vector3d< T >::X, irr::core::vector3d< T >::Y, and irr::core::vector3d< T >::Z.
|
inline |
Constructor which converts a matrix to a quaternion.
Definition at line 201 of file quaternion.h.
|
inline |
Calculates the dot product.
Definition at line 556 of file quaternion.h.
Referenced by quaternion(), and slerp().
|
inline |
returns if this quaternion equals the other one, taking floating point rounding errors into account
Definition at line 500 of file quaternion.h.
References irr::core::equals(), W, X, Y, and Z.
Referenced by quaternion().
|
inline |
Create quaternion from rotation angle and rotation axis.
axis must be unit length, angle in radians
Axis must be unit length. The quaternion representing the rotation is q = cos(A/2)+sin(A/2)*(x*i+y*j+z*k).
angle | Rotation Angle in radians. |
axis | Rotation axis. |
Definition at line 563 of file quaternion.h.
References W, X, irr::core::vector3d< T >::X, Y, irr::core::vector3d< T >::Y, Z, and irr::core::vector3d< T >::Z.
Referenced by quaternion().
|
inline |
Creates a matrix from this quaternion.
Definition at line 338 of file quaternion.h.
Referenced by quaternion().
|
inline |
Creates a matrix from this quaternion.
Creates a matrix from this quaternion
Definition at line 349 of file quaternion.h.
References irr::core::CMatrix4< T >::setDefinitelyIdentityMatrix(), W, X, irr::core::vector3d< T >::X, Y, irr::core::vector3d< T >::Y, Z, and irr::core::vector3d< T >::Z.
|
inline |
Creates a matrix from this quaternion.
Definition at line 411 of file quaternion.h.
References irr::core::CMatrix4< T >::setDefinitelyIdentityMatrix(), W, X, Y, and Z.
Referenced by quaternion().
|
inline |
Creates a matrix from this quaternion Rotate about a center point shortcut for core::quaternion q; q.rotationFromTo ( vin[i].Normal, forward ); q.getMatrixCenter ( lookat, center, newPos );
core::matrix4 m2; m2.setInverseTranslation ( center ); lookat *= m2;
core::matrix4 m3; m2.setTranslation ( newPos ); lookat *= m3;
Creates a matrix from this quaternion Rotate about a center point shortcut for core::quaternion q; q.rotationFromTo(vin[i].Normal, forward); q.getMatrix(lookat, center);
core::matrix4 m2; m2.setInverseTranslation(center); lookat *= m2;
Definition at line 388 of file quaternion.h.
References irr::core::CMatrix4< T >::setRotationCenter(), W, X, Y, and Z.
Referenced by quaternion().
|
inline |
Set this quaternion to the linear interpolation between two quaternions.
q1 | First quaternion to be interpolated. |
q2 | Second quaternion to be interpolated. |
time | Progress of interpolation. For time=0 the result is q1, for time=1 the result is q2. Otherwise interpolation between q1 and q2. |
Definition at line 523 of file quaternion.h.
Referenced by quaternion(), and slerp().
|
inline |
Set quaternion to identity.
Definition at line 649 of file quaternion.h.
Referenced by quaternion(), and rotationFromTo().
|
inline |
|
inline |
Normalizes the quaternion.
Definition at line 510 of file quaternion.h.
References irr::core::reciprocal_squareroot(), W, X, Y, and Z.
Referenced by operator=(), quaternion(), rotationFromTo(), and set().
|
inline |
|
inline |
|
inline |
Multiplication operator with scalar.
Definition at line 308 of file quaternion.h.
References quaternion(), W, X, Y, and Z.
Multiplication operator.
Definition at line 634 of file quaternion.h.
References irr::core::vector3d< T >::crossProduct(), W, X, Y, and Z.
|
inline |
Multiplication operator with scalar.
Definition at line 315 of file quaternion.h.
Referenced by quaternion().
|
inline |
Multiplication operator.
Definition at line 325 of file quaternion.h.
|
inline |
Add operator.
Definition at line 331 of file quaternion.h.
References quaternion(), W, X, Y, and Z.
Referenced by quaternion().
|
inline |
|
inline |
Matrix assignment operator.
Definition at line 234 of file quaternion.h.
References normalize(), W, X, Y, and Z.
|
inline |
|
inline |
Set quaternion to represent a rotation from one vector to another.
Definition at line 658 of file quaternion.h.
References irr::core::vector3d< T >::crossProduct(), irr::core::vector3d< T >::dotProduct(), irr::core::vector3d< T >::getLength(), makeIdentity(), normalize(), irr::core::vector3d< T >::normalize(), irr::core::vector3d< T >::set(), irr::core::vector3d< T >::X, irr::core::vector3d< T >::Y, and irr::core::vector3d< T >::Z.
Referenced by quaternion().
|
inline |
|
inline |
Sets new quaternion based on euler angles (radians)
Definition at line 457 of file quaternion.h.
References normalize(), W, X, Y, and Z.
|
inline |
Sets new quaternion based on euler angles (radians)
Definition at line 487 of file quaternion.h.
References irr::core::vector3d< T >::X, irr::core::vector3d< T >::Y, and irr::core::vector3d< T >::Z.
|
inline |
Sets new quaternion from other quaternion.
Definition at line 493 of file quaternion.h.
|
inline |
Set this quaternion to the result of the spherical interpolation between two quaternions.
q1 | First quaternion to be interpolated. |
q2 | Second quaternion to be interpolated. |
time | Progress of interpolation. For time=0 the result is q1, for time=1 the result is q2. Otherwise interpolation between q1 and q2. |
threshold | To avoid inaccuracies at the end (time=1) the interpolation switches to linear interpolation at some point. This value defines how much of the remaining interpolation will be calculated with lerp. Everything from 1-threshold up will be linear interpolation. |
Definition at line 531 of file quaternion.h.
References dotProduct(), lerp(), and irr::core::reciprocal().
Referenced by quaternion().
|
inline |
Fills an angle (radians) around an axis (unit vector)
Definition at line 575 of file quaternion.h.
References irr::core::iszero(), irr::core::reciprocal(), W, X, irr::core::vector3d< T >::X, Y, irr::core::vector3d< T >::Y, Z, and irr::core::vector3d< T >::Z.
Referenced by quaternion().
|
inline |
Output this quaternion to an euler angle (radians)
Definition at line 596 of file quaternion.h.
References irr::core::clamp(), irr::core::equals(), irr::core::PI64, W, X, irr::core::vector3d< T >::X, Y, irr::core::vector3d< T >::Y, Z, and irr::core::vector3d< T >::Z.
Referenced by quaternion().
f32 irr::core::quaternion::W |
Definition at line 182 of file quaternion.h.
Referenced by dotProduct(), equals(), fromAngleAxis(), getMatrix(), getMatrix_transposed(), getMatrixCenter(), makeIdentity(), normalize(), operator*(), operator*=(), operator+(), operator=(), operator==(), set(), toAngleAxis(), and toEuler().
f32 irr::core::quaternion::X |
Quaternion elements.
Definition at line 179 of file quaternion.h.
Referenced by dotProduct(), equals(), fromAngleAxis(), getMatrix(), getMatrix_transposed(), getMatrixCenter(), makeIdentity(), makeInverse(), normalize(), operator*(), operator*=(), operator+(), operator=(), operator==(), set(), toAngleAxis(), and toEuler().
f32 irr::core::quaternion::Y |
Definition at line 180 of file quaternion.h.
Referenced by dotProduct(), equals(), fromAngleAxis(), getMatrix(), getMatrix_transposed(), getMatrixCenter(), makeIdentity(), makeInverse(), normalize(), operator*(), operator*=(), operator+(), operator=(), operator==(), set(), toAngleAxis(), and toEuler().
f32 irr::core::quaternion::Z |
Definition at line 181 of file quaternion.h.
Referenced by dotProduct(), equals(), fromAngleAxis(), getMatrix(), getMatrix_transposed(), getMatrixCenter(), makeIdentity(), makeInverse(), normalize(), operator*(), operator*=(), operator+(), operator=(), operator==(), set(), toAngleAxis(), and toEuler().