Home | Namespaces | Hierarchy | Alphabetical List | Class list | Files | Namespace Members | Class members | File members | Tutorials

# irr::core::quaternion Class Reference

Quaternion class for representing rotations. More...

`#include <quaternion.h>`

List of all members.

## Public Member Functions
f32 | dotProduct (const quaternion &other) const
| Calculates the dot product.
quaternion & | fromAngleAxis (f32 angle, const vector3df &axis)
| Create quaternion from rotation angle and rotation axis.
void | getMatrix (matrix4 &dest, const core::vector3df &translation) const
| Creates a matrix from this quaternion.
matrix4 | getMatrix () const
| Creates a matrix from this quaternion.
void | getMatrix_transposed (matrix4 &dest) const
| Creates a matrix from this quaternion.
void | getMatrixCenter (matrix4 &dest, const core::vector3df &center, const core::vector3df &translation) const
quaternion & | makeIdentity ()
| Set quaternion to identity.
quaternion & | makeInverse ()
| Inverts this quaternion.
quaternion & | normalize ()
| Normalizes the quaternion.
vector3df | operator* (const vector3df &v) const
| Multiplication operator.
quaternion | operator* (f32 s) const
| Multiplication operator with scalar.
quaternion | operator* (const quaternion &other) const
| Multiplication operator.
quaternion & | operator*= (const quaternion &other)
| Multiplication operator.
quaternion & | operator*= (f32 s)
| Multiplication operator with scalar.
quaternion | operator+ (const quaternion &other) const
| Add operator.
quaternion & | operator= (const matrix4 &other)
| Matrix assignment operator.
quaternion & | operator= (const quaternion &other)
| Assignment operator.
bool | operator== (const quaternion &other) const
| Equalilty operator.
| quaternion (const matrix4 &mat)
| Constructor which converts a matrix to a quaternion.
| quaternion (const vector3df &vec)
| Constructor which converts euler angles (radians) to a quaternion.
| quaternion (f32 x, f32 y, f32 z)
| Constructor which converts euler angles (radians) to a quaternion.
| quaternion (f32 x, f32 y, f32 z, f32 w)
| Constructor.
| quaternion ()
| Default Constructor.
quaternion & | rotationFromTo (const vector3df &from, const vector3df &to)
| Set quaternion to represent a rotation from one vector to another.
quaternion & | set (const core::vector3df &vec)
| Sets new quaternion based on euler angles (radians).
quaternion & | set (f32 x, f32 y, f32 z)
| Sets new quaternion based on euler angles (radians).
quaternion & | set (f32 x, f32 y, f32 z, f32 w)
| Sets new quaternion.
quaternion & | slerp (quaternion q1, quaternion q2, f32 interpolate)
| Set this quaternion to the result of the interpolation between two quaternions.
void | toAngleAxis (f32 &angle, core::vector3df &axis) const
| Fills an angle (radians) around an axis (unit vector).
void | toEuler (vector3df &euler) const
| Output this quaternion to an euler angle (radians).
## Public Attributes
f32 | W
f32 | X
| Quaternion elements.
f32 | Y
f32 | Z

## Detailed Description

Quaternion class for representing rotations.

It provides cheap combinations and avoids gimbal locks. Also useful for interpolations.

Definition at line 21 of file quaternion.h.

## Constructor & Destructor Documentation

irr::core::quaternion::quaternion | ( |  | ) | `[inline]`

Default Constructor.

Definition at line 26 of file quaternion.h.

Referenced by operator*(), and operator+().

irr::core::quaternion::quaternion | ( | f32 | x,
|  | f32 | y,
|  | f32 | z,
|  | f32 | w |
| ) |  |  | `[inline]`

Constructor.

Definition at line 29 of file quaternion.h.

irr::core::quaternion::quaternion | ( | f32 | x,
|  | f32 | y,
|  | f32 | z |
| ) |  |  | `[inline]`

Constructor which converts euler angles (radians) to a quaternion.

Definition at line 145 of file quaternion.h.

irr::core::quaternion::quaternion | ( | const vector3df & | vec | ) | `[inline]`

Constructor which converts euler angles (radians) to a quaternion.

Definition at line 152 of file quaternion.h.

References irr::core::vector3d< T >::X, irr::core::vector3d< T >::Y, and irr::core::vector3d< T >::Z.

irr::core::quaternion::quaternion | ( | const matrix4 & | mat | ) | `[inline]`

Constructor which converts a matrix to a quaternion.

Definition at line 159 of file quaternion.h.

## Member Function Documentation

f32 irr::core::quaternion::dotProduct | ( | const quaternion & | other | ) | const`[inline]`

Calculates the dot product.

Definition at line 502 of file quaternion.h.

References W, X, Y, and Z.

Referenced by slerp().

quaternion & irr::core::quaternion::fromAngleAxis | ( | f32 | angle,
|  | const vector3df & | axis |
| ) |  |  | `[inline]`

Create quaternion from rotation angle and rotation axis.

Axis must be unit length. The quaternion representing the rotation is q = cos(A/2)+sin(A/2)*(x*i+y*j+z*k).

Parameters:

  | angle | Rotation Angle in radians.
  | axis | Rotation axis.

axis must be unit length angle in radians

Definition at line 510 of file quaternion.h.

References W, irr::core::vector3d< T >::X, X, irr::core::vector3d< T >::Y, Y, irr::core::vector3d< T >::Z, and Z.

void irr::core::quaternion::getMatrix | ( | matrix4 & | dest,
|  | const core::vector3df & | center |
| ) |  |  | const`[inline]`

Creates a matrix from this quaternion.

Creates a matrix from this quaternion

Definition at line 300 of file quaternion.h.

References irr::core::CMatrix4< T >::pointer(), irr::core::CMatrix4< T >::setDefinitelyIdentityMatrix(), W, irr::core::vector3d< T >::X, X, irr::core::vector3d< T >::Y, Y, irr::core::vector3d< T >::Z, and Z.

matrix4 irr::core::quaternion::getMatrix | ( |  | ) | const`[inline]`

Creates a matrix from this quaternion.

Definition at line 289 of file quaternion.h.

References getMatrix_transposed().

Referenced by irr::scene::SMD3QuaternionTag::setto().

void irr::core::quaternion::getMatrix_transposed | ( | matrix4 & | dest | ) | const`[inline]`

Creates a matrix from this quaternion.

Definition at line 367 of file quaternion.h.

References irr::core::CMatrix4< T >::setDefinitelyIdentityMatrix(), W, X, Y, and Z.

Referenced by getMatrix().

void irr::core::quaternion::getMatrixCenter | ( | matrix4 & | dest,
|  | const core::vector3df & | center,
|  | const core::vector3df & | translation |
| ) |  |  | const`[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 342 of file quaternion.h.

References irr::core::CMatrix4< T >::pointer(), irr::core::CMatrix4< T >::setRotationCenter(), W, X, Y, and Z.

core::quaternion & irr::core::quaternion::makeIdentity | ( |  | ) | `[inline]`

Set quaternion to identity.

Definition at line 576 of file quaternion.h.

References W, X, Y, and Z.

Referenced by rotationFromTo().

quaternion & irr::core::quaternion::makeInverse | ( |  | ) | `[inline]`

Inverts this quaternion.

Definition at line 395 of file quaternion.h.

References X, Y, and Z.

quaternion & irr::core::quaternion::normalize | ( |  | ) | `[inline]`

Normalizes the quaternion.

Definition at line 449 of file quaternion.h.

References irr::core::reciprocal_squareroot(), W, X, Y, and Z.

Referenced by operator=(), and set().

vector3df irr::core::quaternion::operator* | ( | const vector3df & | v | ) | const`[inline]`

Multiplication operator.

Definition at line 561 of file quaternion.h.

References irr::core::vector3d< T >::crossProduct(), W, X, Y, and Z.

quaternion irr::core::quaternion::operator* | ( | f32 | s | ) | const`[inline]`

Multiplication operator with scalar.

Definition at line 260 of file quaternion.h.

References quaternion(), W, X, Y, and Z.

quaternion irr::core::quaternion::operator* | ( | const quaternion & | other | ) | const`[inline]`

Multiplication operator.

Definition at line 246 of file quaternion.h.

References W, X, Y, and Z.

quaternion & irr::core::quaternion::operator*= | ( | const quaternion & | other | ) | `[inline]`

Multiplication operator.

Definition at line 276 of file quaternion.h.

quaternion & irr::core::quaternion::operator*= | ( | f32 | s | ) | `[inline]`

Multiplication operator with scalar.

Definition at line 266 of file quaternion.h.

References W, X, Y, and Z.

quaternion irr::core::quaternion::operator+ | ( | const quaternion & | other | ) | const`[inline]`

Add operator.

Definition at line 282 of file quaternion.h.

References quaternion(), W, X, Y, and Z.

quaternion & irr::core::quaternion::operator= | ( | const matrix4 & | other | ) | `[inline]`

Matrix assignment operator.

Definition at line 187 of file quaternion.h.

References normalize(), W, X, Y, and Z.

quaternion & irr::core::quaternion::operator= | ( | const quaternion & | other | ) | `[inline]`

Assignment operator.

Definition at line 176 of file quaternion.h.

References W, X, Y, and Z.

bool irr::core::quaternion::operator== | ( | const quaternion & | other | ) | const`[inline]`

Equalilty operator.

Definition at line 166 of file quaternion.h.

References W, X, Y, and Z.

core::quaternion & irr::core::quaternion::rotationFromTo | ( | const vector3df & | from,
|  | const vector3df & | to |
| ) |  |  | `[inline]`

Set quaternion to represent a rotation from one vector to another.

Definition at line 585 of file quaternion.h.

References irr::core::vector3d< T >::crossProduct(), irr::core::vector3d< T >::dotProduct(), makeIdentity(), irr::core::vector3d< T >::normalize(), W, irr::core::vector3d< T >::X, X, irr::core::vector3d< T >::Y, Y, irr::core::vector3d< T >::Z, and Z.

quaternion & irr::core::quaternion::set | ( | const core::vector3df & | vec | ) | `[inline]`

Sets new quaternion based on euler angles (radians).

Definition at line 443 of file quaternion.h.

References irr::core::vector3d< T >::X, irr::core::vector3d< T >::Y, and irr::core::vector3d< T >::Z.

quaternion & irr::core::quaternion::set | ( | f32 | x,
|  | f32 | y,
|  | f32 | z |
| ) |  |  | `[inline]`

Sets new quaternion based on euler angles (radians).

Definition at line 413 of file quaternion.h.

References normalize(), W, X, Y, and Z.

quaternion & irr::core::quaternion::set | ( | f32 | x,
|  | f32 | y,
|  | f32 | z,
|  | f32 | w |
| ) |  |  | `[inline]`

Sets new quaternion.

Definition at line 402 of file quaternion.h.

References W, X, Y, and Z.

Referenced by slerp().

quaternion & irr::core::quaternion::slerp | ( | quaternion | q1,
|  | quaternion | q2,
|  | f32 | interpolate |
| ) |  |  | `[inline]`

Set this quaternion to the result of the interpolation between two quaternions.

Definition at line 462 of file quaternion.h.

References dotProduct(), irr::core::PI, irr::core::reciprocal(), set(), W, X, Y, and Z.

void irr::core::quaternion::toAngleAxis | ( | f32 & | angle,
|  | core::vector3df & | axis |
| ) |  |  | const`[inline]`

Fills an angle (radians) around an axis (unit vector).

Definition at line 522 of file quaternion.h.

References irr::core::iszero(), irr::core::reciprocal(), W, irr::core::vector3d< T >::X, X, irr::core::vector3d< T >::Y, Y, irr::core::vector3d< T >::Z, and Z.

void irr::core::quaternion::toEuler | ( | vector3df & | euler | ) | const`[inline]`

Output this quaternion to an euler angle (radians).

Definition at line 543 of file quaternion.h.

References irr::core::clamp(), W, irr::core::vector3d< T >::X, X, irr::core::vector3d< T >::Y, Y, irr::core::vector3d< T >::Z, and Z.

## Member Data Documentation

f32 irr::core::quaternion::W

Definition at line 140 of file quaternion.h.

Referenced by dotProduct(), fromAngleAxis(), getMatrix(), getMatrix_transposed(), getMatrixCenter(), makeIdentity(), normalize(), operator*(), operator*=(), operator+(), operator=(), operator==(), rotationFromTo(), set(), slerp(), toAngleAxis(), and toEuler().

f32 irr::core::quaternion::X

Quaternion elements.

Definition at line 137 of file quaternion.h.

Referenced by dotProduct(), fromAngleAxis(), getMatrix(), getMatrix_transposed(), getMatrixCenter(), makeIdentity(), makeInverse(), normalize(), operator*(), operator*=(), operator+(), operator=(), operator==(), rotationFromTo(), set(), slerp(), toAngleAxis(), and toEuler().

f32 irr::core::quaternion::Y

Definition at line 138 of file quaternion.h.

Referenced by dotProduct(), fromAngleAxis(), getMatrix(), getMatrix_transposed(), getMatrixCenter(), makeIdentity(), makeInverse(), normalize(), operator*(), operator*=(), operator+(), operator=(), operator==(), rotationFromTo(), set(), slerp(), toAngleAxis(), and toEuler().

f32 irr::core::quaternion::Z

Definition at line 139 of file quaternion.h.

Referenced by dotProduct(), fromAngleAxis(), getMatrix(), getMatrix_transposed(), getMatrixCenter(), makeIdentity(), makeInverse(), normalize(), operator*(), operator*=(), operator+(), operator=(), operator==(), rotationFromTo(), set(), slerp(), toAngleAxis(), and toEuler().

The documentation for this class was generated from the following file:

- quaternion.h

| The Irrlicht Engine Documentation © 2003-2009 by Nikolaus Gebhardt. Generated on Sun Jan 10 09:24:09 2010 by Doxygen (1.5.6)