gKit2 light
|
A Quaternion class. More...
#include <quaternion.h>
Public Member Functions | |
Defining a Quaternion | |
TQuaternion () | |
TQuaternion (const Vec3Real &axis, const Real angle) | |
TQuaternion (const Vec3Real &from, const Vec3Real &to) | |
TQuaternion (Real q0, Real q1, Real q2, Real q3) | |
TQuaternion (const TQuaternion &Q) | |
TQuaternion & | operator= (const TQuaternion &Q) |
TQuaternion & | operator+= (const TQuaternion &Q) |
void | setAxisAngle (const Vec3Real &axis, const Real angle) |
void | setValue (Real q0, Real q1, Real q2, Real q3) |
template<typename MAT > | |
void | setFromRotationMatrix (const MAT &m) |
void | setFromRotatedBase (const Vec3Real &X, const Vec3Real &Y, const Vec3Real &Z) |
Inversion | |
TQuaternion | inverse () const |
void | invert () |
void | negate () |
Real | normalize () |
Associated matrix | |
const Real * | matrix () const |
template<typename MAT > | |
void | getMatrix44 (MAT &m) const |
template<typename MAT > | |
void | getMatrix33 (MAT &m) const |
void | getMatrix16 (Real m[16]) const |
void | getRotationMatrix (Real m[3][3]) const |
const Real * | inverseMatrix () const |
void | getInverseMatrix (Real m[4][4]) const |
void | getInverseMatrix (Real m[16]) const |
void | getInverseRotationMatrix (Real m[3][3]) const |
Static Public Member Functions | |
Random TQuaternion | |
static TQuaternion | randomQuaternion () |
XML representation | |
std::ostream & | operator<< (std::ostream &o, const TQuaternion &Q) |
Accessing values | |
Vec3Real | axis () const |
Real | angle () const |
void | getAxisAngle (Vec3Real &axis, Real &angle) const |
Real | operator[] (int i) const |
Real & | operator[] (int i) |
TQuaternion | operator* (const Real a, const TQuaternion &b) |
Rotation computations | |
TQuaternion & | operator*= (const TQuaternion &q) |
Vec3Real | rotate (const Vec3Real &v) const |
Vec3Real | inverseRotate (const Vec3Real &v) const |
TQuaternion | operator* (const TQuaternion &a, const TQuaternion &b) |
Vec3Real | operator* (const TQuaternion &q, const Vec3Real &v) |
Slerp interpolation | |
TQuaternion | log () |
TQuaternion | exp () |
static TQuaternion | slerp (const TQuaternion &a, const TQuaternion &b, Real t, bool allowFlip=true) |
static TQuaternion | squad (const TQuaternion &a, const TQuaternion &tgA, const TQuaternion &tgB, const TQuaternion &b, Real t) |
static Real | dot (const TQuaternion &a, const TQuaternion &b) |
static TQuaternion | lnDif (const TQuaternion &a, const TQuaternion &b) |
static TQuaternion | squadTangent (const TQuaternion &before, const TQuaternion ¢er, const TQuaternion &after) |
A Quaternion class.
Definition at line 36 of file quaternion.h.
|
inline |
Default constructor, builds an identity rotation.
Definition at line 42 of file quaternion.h.
|
inline |
Constructor from rotation axis (non null) and angle (in radians). See also setAxisAngle().
Definition at line 46 of file quaternion.h.
|
inline |
Constructor from the four values of a TQuaternion. First three values are axis*sin(angle/2) and last one is cos(angle/2).
Definition at line 90 of file quaternion.h.
|
inline |
Copy constructor.
Definition at line 94 of file quaternion.h.
|
inline |
Equal operator.
Definition at line 98 of file quaternion.h.
|
inline |
Sets the TQuaternion as a rotation of axis axis
and angle angle
(in radians).
axis
does not need to be normalized. A null axis
will result in an identity TQuaternion.
Definition at line 116 of file quaternion.h.
|
inline |
Sets the TQuaternion value. See the TQuaternion(Real, Real, Real, Real) constructor documentation.
Definition at line 138 of file quaternion.h.
|
inline |
Bracket operator, with a constant return value. i
must range in [0..3]. See the TQuaternion(Real, Real, Real, Real) documentation.
Definition at line 243 of file quaternion.h.
|
inline |
Bracket operator returning an l-value. i
must range in [0..3]. See the TQuaternion(Real, Real, Real, Real) documentation.
Definition at line 246 of file quaternion.h.
|
inline |
TQuaternion rotation is composed with q
.
See operator*(), since this is equivalent to this
= this
* q
.
Definition at line 282 of file quaternion.h.
|
inline |
Returns the inverse TQuaternion (inverse rotation).
Result has a negated axis() direction and the same angle(). A composition (see operator*()) of a TQuaternion and its inverse() results in an identity function.
Use invert() to actually modify the TQuaternion.
Definition at line 337 of file quaternion.h.
|
inline |
Inverses the TQuaternion (same rotation angle(), but negated axis()).
See also inverse().
Definition at line 342 of file quaternion.h.
|
inline |
Negates all the coefficients of the TQuaternion.
This results in an other representation of the same rotation (opposite rotation angle, but with a negated axis direction: the two cancel out). However, note that the results of axis() and angle() are unchanged after a call to this method since angle() always returns a value in [0,pi].
This method is mainly useful for TQuaternion interpolation, so that the spherical interpolation takes the shortest path on the unit sphere. See slerp() for details.
Definition at line 352 of file quaternion.h.
|
inline |
Normalizes the TQuaternion coefficients.
This method should not need to be called since we only deal with unit TQuaternions. This is however useful to prevent numerical drifts, especially with small rotational increments.
Definition at line 358 of file quaternion.h.
|
inline |
Returns the TQuaternion associated 4x4 OpenGL rotation matrix.
Use glMultMatrixd
(q.matrix()) or glLoadMatrixd
(q.matrix()) to apply the TQuaternion rotation to the current OpenGL matrix.
See also getMatrix(), getRotationMatrix() and inverseMatrix().
Definition at line 381 of file quaternion.h.
|
inline |
Fills m
with the OpenGL representation of the TQuaternion rotation.
Use matrix() if you do not need to store this matrix and simply want to alter the current OpenGL matrix. See also getInverseMatrix() and Frame::getMatrix().
Definition at line 395 of file quaternion.h.
|
inline |
Fills m
with the OpenGL representation of the TQuaternion rotation.
Use matrix() if you do not need to store this matrix and simply want to alter the current OpenGL matrix. See also getInverseMatrix() and Frame::getMatrix().
Definition at line 438 of file quaternion.h.
|
inline |
Fills m
with the 3x3 rotation matrix associated with the TQuaternion. See also getInverseRotationMatrix().
m
uses the European mathematical representation of the rotation matrix. Use matrix() and getMatrix() to retrieve the OpenGL transposed version. Definition at line 481 of file quaternion.h.
|
inline |
Returns the associated 4x4 OpenGL inverse rotation matrix. This is simply the matrix() of the inverse().
glMultMatrixd
(q.inverseMatrix())) or use getInverseMatrix() instead. Definition at line 497 of file quaternion.h.
|
inline |
Fills m
with the OpenGL matrix corresponding to the inverse() rotation.
Use inverseMatrix() if you do not need to store this matrix and simply want to alter the current OpenGL matrix. See also getMatrix().
Definition at line 508 of file quaternion.h.
|
inline |
m
is set to the 3x3 inverse rotation matrix associated with the TQuaternion.
Definition at line 524 of file quaternion.h.
|
inlinestatic |
Returns the "dot" product of a
and b:
a[0]*b[0] + a[1]*b[1] + a[2]*b[2] + a[3]*b[3].
Definition at line 576 of file quaternion.h.
|
friend |
|
friend |
Returns the composition of the a
and b
rotations. The order is important. When applied to a Vec v
(see operator*(const TQuaternion&, const Vec&) and rotate()) the resulting TQuaternion acts as if b
was applied first and then a
was applied. This is obvious since the image v'
of v
by the composited rotation satisfies:
Note that a*b usually differs from b*a.
Definition at line 268 of file quaternion.h.
|
friend |
Returns the image of v
by the rotation q
.
Same as q.rotate(v). See rotate() and inverseRotate().
Definition at line 291 of file quaternion.h.