Ogre::Quaternion Class Reference
Math

Implementation of a Quaternion, i.e. More...

`#include <OgreQuaternion.h>`

List of all members.

## Public Member Functions

| Quaternion (Real fW=1.0, Real fX=0.0, Real fY=0.0, Real fZ=0.0)
| Quaternion (const Matrix3 &rot)
| Construct a quaternion from a rotation matrix.
| Quaternion (const Radian &rfAngle, const Vector3 &rkAxis)
| Construct a quaternion from an angle/axis.
| Quaternion (const Vector3 &xaxis, const Vector3 &yaxis, const Vector3 &zaxis)
| Construct a quaternion from 3 orthonormal local axes.
| Quaternion (const Vector3 *akAxis)
| Construct a quaternion from 3 orthonormal local axes.
| Quaternion (Real *valptr)
| Construct a quaternion from 4 manual w/x/y/z values.
void | swap (Quaternion &other)
| Exchange the contents of this quaternion with another.
Real | operator[] (const size_t i) const
| Array accessor operator.
Real & | operator[] (const size_t i)
| Array accessor operator.
Real * | ptr ()
| Pointer accessor for direct copying.
const Real * | ptr () const
| Pointer accessor for direct copying.
void | FromRotationMatrix (const Matrix3 &kRot)
void | ToRotationMatrix (Matrix3 &kRot) const
void | FromAngleAxis (const Radian &rfAngle, const Vector3 &rkAxis)
void | ToAngleAxis (Radian &rfAngle, Vector3 &rkAxis) const
void | ToAngleAxis (Degree &dAngle, Vector3 &rkAxis) const
void | FromAxes (const Vector3 *akAxis)
void | FromAxes (const Vector3 &xAxis, const Vector3 &yAxis, const Vector3 &zAxis)
void | ToAxes (Vector3 *akAxis) const
void | ToAxes (Vector3 &xAxis, Vector3 &yAxis, Vector3 &zAxis) const
Vector3 | xAxis (void) const
| Get the local x-axis.
Vector3 | yAxis (void) const
| Get the local y-axis.
Vector3 | zAxis (void) const
| Get the local z-axis.
Quaternion & | operator= (const Quaternion &rkQ)
Quaternion | operator+ (const Quaternion &rkQ) const
Quaternion | operator- (const Quaternion &rkQ) const
Quaternion | operator* (const Quaternion &rkQ) const
Quaternion | operator* (Real fScalar) const
Quaternion | operator- () const
bool | operator== (const Quaternion &rhs) const
bool | operator!= (const Quaternion &rhs) const
Real | Dot (const Quaternion &rkQ) const
Real | Norm () const
Real | normalise (void)
| Normalises this quaternion, and returns the previous length.
Quaternion | Inverse () const
Quaternion | UnitInverse () const
Quaternion | Exp () const
Quaternion | Log () const
Vector3 | operator* (const Vector3 &rkVector) const
Radian | getRoll (bool reprojectAxis=true) const
| Calculate the local roll element of this quaternion.
Radian | getPitch (bool reprojectAxis=true) const
| Calculate the local pitch element of this quaternion.
Radian | getYaw (bool reprojectAxis=true) const
| Calculate the local yaw element of this quaternion.
bool | equals (const Quaternion &rhs, const Radian &tolerance) const
| Equality with tolerance (tolerance is max angle difference)
bool | isNaN () const
| Check whether this quaternion contains valid values.

## Static Public Member Functions

static Quaternion | Slerp (Real fT, const Quaternion &rkP, const Quaternion &rkQ, bool shortestPath=false)
static Quaternion | SlerpExtraSpins (Real fT, const Quaternion &rkP, const Quaternion &rkQ, int iExtraSpins)
static void | Intermediate (const Quaternion &rkQ0, const Quaternion &rkQ1, const Quaternion &rkQ2, Quaternion &rka, Quaternion &rkB)
static Quaternion | Squad (Real fT, const Quaternion &rkP, const Quaternion &rkA, const Quaternion &rkB, const Quaternion &rkQ, bool shortestPath=false)
static Quaternion | nlerp (Real fT, const Quaternion &rkP, const Quaternion &rkQ, bool shortestPath=false)

## Public Attributes

Real | w
Real | x
Real | y
Real | z

## Static Public Attributes

static const Real | ms_fEpsilon
static const Quaternion | ZERO
static const Quaternion | IDENTITY

## Friends

_OgreExport friend Quaternion | operator* (Real fScalar, const Quaternion &rkQ)
_OgreExport friend std::ostream & | operator<< (std::ostream &o, const Quaternion &q)
| Function for writing to a stream.

## Detailed Description

Implementation of a Quaternion, i.e.

a rotation around an axis.

Definition at line 52 of file OgreQuaternion.h.

## Constructor & Destructor Documentation

Ogre::Quaternion::Quaternion | ( | Real | fW = `1.0`,
|  | Real | fX = `0.0`,
|  | Real | fY = `0.0`,
|  | Real | fZ = `0.0`
| ) |  |

Definition at line 55 of file OgreQuaternion.h.

Ogre::Quaternion::Quaternion | ( | const Matrix3 & | rot | ) |

Construct a quaternion from a rotation matrix.

Definition at line 65 of file OgreQuaternion.h.

Ogre::Quaternion::Quaternion | ( | const Radian & | rfAngle,
|  | const Vector3 & | rkAxis
| ) |  |

Construct a quaternion from an angle/axis.

Definition at line 70 of file OgreQuaternion.h.

Ogre::Quaternion::Quaternion | ( | const Vector3 & | xaxis,
|  | const Vector3 & | yaxis,
|  | const Vector3 & | zaxis
| ) |  |

Construct a quaternion from 3 orthonormal local axes.

Definition at line 75 of file OgreQuaternion.h.

Ogre::Quaternion::Quaternion | ( | const Vector3 * | akAxis | ) |

Construct a quaternion from 3 orthonormal local axes.

Definition at line 80 of file OgreQuaternion.h.

Ogre::Quaternion::Quaternion | ( | Real * | valptr | ) |

Construct a quaternion from 4 manual w/x/y/z values.

Definition at line 85 of file OgreQuaternion.h.

## Member Function Documentation

Real Ogre::Quaternion::Dot | ( | const Quaternion & | rkQ | ) | const

bool Ogre::Quaternion::equals | ( | const Quaternion & | rhs,
|  | const Radian & | tolerance
| ) |  | const

Equality with tolerance (tolerance is max angle difference)

Quaternion Ogre::Quaternion::Exp | ( |  | ) | const

void Ogre::Quaternion::FromAngleAxis | ( | const Radian & | rfAngle,
|  | const Vector3 & | rkAxis
| ) |  |

Referenced by Ogre::Vector3::getRotationTo(), and Ogre::Vector3::randomDeviant().

void Ogre::Quaternion::FromAxes | ( | const Vector3 * | akAxis | ) |

void Ogre::Quaternion::FromAxes | ( | const Vector3 & | xAxis,
|  | const Vector3 & | yAxis,
|  | const Vector3 & | zAxis
| ) |  |

void Ogre::Quaternion::FromRotationMatrix | ( | const Matrix3 & | kRot | ) |

Radian Ogre::Quaternion::getPitch | ( | bool | reprojectAxis = `true` | ) | const

Calculate the local pitch element of this quaternion.

Parameters:

  reprojectAxis | By default the method returns the 'intuitive' result that is, if you projected the local Z of the quaternion onto the X and Y axes, the angle between them is returned. If set to true though, the result is the actual yaw that will be used to implement the quaternion, which is the shortest possible path to get to the same orientation and may involve less axial rotation.

Radian Ogre::Quaternion::getRoll | ( | bool | reprojectAxis = `true` | ) | const

Calculate the local roll element of this quaternion.

Parameters:

  reprojectAxis | By default the method returns the 'intuitive' result that is, if you projected the local Y of the quaternion onto the X and Y axes, the angle between them is returned. If set to false though, the result is the actual yaw that will be used to implement the quaternion, which is the shortest possible path to get to the same orientation and may involve less axial rotation.

Radian Ogre::Quaternion::getYaw | ( | bool | reprojectAxis = `true` | ) | const

Calculate the local yaw element of this quaternion.

Parameters:

  reprojectAxis | By default the method returns the 'intuitive' result that is, if you projected the local Z of the quaternion onto the X and Z axes, the angle between them is returned. If set to true though, the result is the actual yaw that will be used to implement the quaternion, which is the shortest possible path to get to the same orientation and may involve less axial rotation.

static void Ogre::Quaternion::Intermediate | ( | const Quaternion & | rkQ0,
|  | const Quaternion & | rkQ1,
|  | const Quaternion & | rkQ2,
|  | Quaternion & | rka,
|  | Quaternion & | rkB
| ) |  | `[static]`

Quaternion Ogre::Quaternion::Inverse | ( |  | ) | const

bool Ogre::Quaternion::isNaN | ( |  | ) | const

Check whether this quaternion contains valid values.

Definition at line 247 of file OgreQuaternion.h.

References Ogre::Math::isNaN().

Quaternion Ogre::Quaternion::Log | ( |  | ) | const

static Quaternion Ogre::Quaternion::nlerp | ( | Real | fT,
|  | const Quaternion & | rkP,
|  | const Quaternion & | rkQ,
|  | bool | shortestPath = `false`
| ) |  | `[static]`

Real Ogre::Quaternion::Norm | ( |  | ) | const

Real Ogre::Quaternion::normalise | ( | void |  | ) |

Normalises this quaternion, and returns the previous length.

Referenced by Ogre::Vector3::getRotationTo().

bool Ogre::Quaternion::operator!= | ( | const Quaternion & | rhs | ) | const

Definition at line 168 of file OgreQuaternion.h.

References Ogre::operator==().

Vector3 Ogre::Quaternion::operator* | ( | const Vector3 & | rkVector | ) | const

Quaternion Ogre::Quaternion::operator* | ( | const Quaternion & | rkQ | ) | const

Quaternion Ogre::Quaternion::operator* | ( | Real | fScalar | ) | const

Quaternion Ogre::Quaternion::operator+ | ( | const Quaternion & | rkQ | ) | const

Quaternion Ogre::Quaternion::operator- | ( |  | ) | const

Quaternion Ogre::Quaternion::operator- | ( | const Quaternion & | rkQ | ) | const

Quaternion& Ogre::Quaternion::operator= | ( | const Quaternion & | rkQ | ) |

Definition at line 148 of file OgreQuaternion.h.

References w, x, y, and z.

bool Ogre::Quaternion::operator== | ( | const Quaternion & | rhs | ) | const

Definition at line 163 of file OgreQuaternion.h.

References w, x, y, and z.

Real Ogre::Quaternion::operator[] | ( | const size_t | i | ) | const

Array accessor operator.

Definition at line 101 of file OgreQuaternion.h.

Real& Ogre::Quaternion::operator[] | ( | const size_t | i | ) |

Array accessor operator.

Definition at line 109 of file OgreQuaternion.h.

Real* Ogre::Quaternion::ptr | ( |  | ) |

Pointer accessor for direct copying.

Definition at line 117 of file OgreQuaternion.h.

Referenced by Ogre::AnimableValue::setAsBaseValue().

const Real* Ogre::Quaternion::ptr | ( |  | ) | const

Pointer accessor for direct copying.

Definition at line 123 of file OgreQuaternion.h.

static Quaternion Ogre::Quaternion::Slerp | ( | Real | fT,
|  | const Quaternion & | rkP,
|  | const Quaternion & | rkQ,
|  | bool | shortestPath = `false`
| ) |  | `[static]`

static Quaternion Ogre::Quaternion::SlerpExtraSpins | ( | Real | fT,
|  | const Quaternion & | rkP,
|  | const Quaternion & | rkQ,
|  | int | iExtraSpins
| ) |  | `[static]`

static Quaternion Ogre::Quaternion::Squad | ( | Real | fT,
|  | const Quaternion & | rkP,
|  | const Quaternion & | rkA,
|  | const Quaternion & | rkB,
|  | const Quaternion & | rkQ,
|  | bool | shortestPath = `false`
| ) |  | `[static]`

void Ogre::Quaternion::swap | ( | Quaternion & | other | ) |

Exchange the contents of this quaternion with another.

Definition at line 92 of file OgreQuaternion.h.

References w, x, y, and z.

void Ogre::Quaternion::ToAngleAxis | ( | Radian & | rfAngle,
|  | Vector3 & | rkAxis
| ) |  | const

void Ogre::Quaternion::ToAngleAxis | ( | Degree & | dAngle,
|  | Vector3 & | rkAxis
| ) |  | const

Definition at line 132 of file OgreQuaternion.h.

void Ogre::Quaternion::ToAxes | ( | Vector3 & | xAxis,
|  | Vector3 & | yAxis,
|  | Vector3 & | zAxis
| ) |  | const

void Ogre::Quaternion::ToAxes | ( | Vector3 * | akAxis | ) | const

void Ogre::Quaternion::ToRotationMatrix | ( | Matrix3 & | kRot | ) | const

Referenced by Ogre::Matrix4::Matrix4().

Quaternion Ogre::Quaternion::UnitInverse | ( |  | ) | const

Vector3 Ogre::Quaternion::xAxis | ( | void |  | ) | const

Get the local x-axis.

Vector3 Ogre::Quaternion::yAxis | ( | void |  | ) | const

Get the local y-axis.

Vector3 Ogre::Quaternion::zAxis | ( | void |  | ) | const

Get the local z-axis.

## Friends And Related Function Documentation

_OgreExport friend Quaternion operator* | ( | Real | fScalar,
|  | const Quaternion & | rkQ
| ) |  | `[friend]`

_OgreExport friend std::ostream& operator<< | ( | std::ostream & | o,
|  | const Quaternion & | q
| ) |  | `[friend]`

Function for writing to a stream.

Outputs "Quaternion(w, x, y, z)" with w,x,y,z being the member values of the quaternion.

Definition at line 256 of file OgreQuaternion.h.

## Member Data Documentation

const Quaternion Ogre::Quaternion::IDENTITY`[static]`

Definition at line 242 of file OgreQuaternion.h.

Referenced by Ogre::Vector3::getRotationTo().

const Real Ogre::Quaternion::ms_fEpsilon`[static]`

Definition at line 238 of file OgreQuaternion.h.

Real Ogre::Quaternion::w

Definition at line 244 of file OgreQuaternion.h.

Referenced by Ogre::Vector3::getRotationTo(), operator=(), operator==(), and swap().

Real Ogre::Quaternion::x

Definition at line 244 of file OgreQuaternion.h.

Referenced by Ogre::Vector3::getRotationTo(), operator=(), operator==(), and swap().

Real Ogre::Quaternion::y

Definition at line 244 of file OgreQuaternion.h.

Referenced by Ogre::Vector3::getRotationTo(), operator=(), operator==(), and swap().

Real Ogre::Quaternion::z

Definition at line 244 of file OgreQuaternion.h.

Referenced by Ogre::Vector3::getRotationTo(), operator=(), operator==(), and swap().

const Quaternion Ogre::Quaternion::ZERO`[static]`

Definition at line 241 of file OgreQuaternion.h.

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

- OgreQuaternion.h

Copyright © 2008 Torus Knot Software Ltd
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.
Last modified Sat Jan 14 2012 18:40:51