OGRE
1.9.0
|
Implementation of a Quaternion, i.e. More...
#include <OgreQuaternion.h>
Public Member Functions | |
Quaternion () | |
Default constructor, initializes to identity rotation (aka 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. | |
Quaternion (Real fW, Real fX, Real fY, Real fZ) | |
Construct from an explicit list of values. | |
Real | Dot (const Quaternion &rkQ) const |
Returns the dot product of the quaternion. | |
bool | equals (const Quaternion &rhs, const Radian &tolerance) const |
Equality with tolerance (tolerance is max angle difference) | |
Quaternion | Exp () const |
Apply to unit-length quaternion. | |
void | FromAngleAxis (const Radian &rfAngle, const Vector3 &rkAxis) |
Setups the quaternion using the supplied vector, and "roll" around that vector by the specified radians. | |
void | FromAxes (const Vector3 &xAxis, const Vector3 &yAxis, const Vector3 &zAxis) |
void | FromAxes (const Vector3 *akAxis) |
Constructs the quaternion using 3 axes, the axes are assumed to be orthonormal. | |
void | FromRotationMatrix (const Matrix3 &kRot) |
Radian | getPitch (bool reprojectAxis=true) const |
Calculate the local pitch element of this quaternion. | |
Radian | getRoll (bool reprojectAxis=true) const |
Calculate the local roll element of this quaternion. | |
Radian | getYaw (bool reprojectAxis=true) const |
Calculate the local yaw element of this quaternion. | |
Quaternion | Inverse () const |
bool | isNaN () const |
Check whether this quaternion contains valid values. | |
Quaternion | Log () const |
Real | Norm () const |
Real | normalise (void) |
Normalises this quaternion, and returns the previous length. | |
bool | operator!= (const Quaternion &rhs) const |
Quaternion | operator* (const Quaternion &rkQ) const |
Vector3 | operator* (const Vector3 &rkVector) const |
Rotation of a vector by a quaternion. | |
Quaternion | operator* (Real fScalar) const |
Quaternion | operator+ (const Quaternion &rkQ) const |
Quaternion | operator- () const |
Quaternion | operator- (const Quaternion &rkQ) const |
Quaternion & | operator= (const Quaternion &rkQ) |
bool | operator== (const Quaternion &rhs) const |
Real & | operator[] (const size_t i) |
Array accessor operator. | |
Real | operator[] (const size_t i) const |
Array accessor operator. | |
bool | orientationEquals (const Quaternion &other, Real tolerance=1e-3) const |
Compare two quaternions which are assumed to be used as orientations. | |
Real * | ptr () |
Pointer accessor for direct copying. | |
const Real * | ptr () const |
Pointer accessor for direct copying. | |
void | swap (Quaternion &other) |
Exchange the contents of this quaternion with another. | |
void | ToAngleAxis (Degree &dAngle, Vector3 &rkAxis) const |
void | ToAngleAxis (Radian &rfAngle, Vector3 &rkAxis) const |
void | ToAxes (Vector3 &xAxis, Vector3 &yAxis, Vector3 &zAxis) const |
void | ToAxes (Vector3 *akAxis) const |
Gets the 3 orthonormal axes defining the quaternion. | |
void | ToRotationMatrix (Matrix3 &kRot) const |
Quaternion | UnitInverse () const |
Apply to non-zero quaternion. | |
Vector3 | xAxis (void) const |
Returns the X orthonormal axis defining the quaternion. | |
Vector3 | yAxis (void) const |
Returns the Y orthonormal axis defining the quaternion. | |
Vector3 | zAxis (void) const |
Returns the Z orthonormal axis defining the quaternion. | |
Static Public Member Functions | |
static void | Intermediate (const Quaternion &rkQ0, const Quaternion &rkQ1, const Quaternion &rkQ2, Quaternion &rka, Quaternion &rkB) |
Setup for spherical quadratic interpolation. | |
static Quaternion | nlerp (Real fT, const Quaternion &rkP, const Quaternion &rkQ, bool shortestPath=false) |
Performs Normalised linear interpolation between two quaternions, and returns the result. | |
static Quaternion | Slerp (Real fT, const Quaternion &rkP, const Quaternion &rkQ, bool shortestPath=false) |
Performs Spherical linear interpolation between two quaternions, and returns the result. | |
static Quaternion | SlerpExtraSpins (Real fT, const Quaternion &rkP, const Quaternion &rkQ, int iExtraSpins) |
static Quaternion | Squad (Real fT, const Quaternion &rkP, const Quaternion &rkA, const Quaternion &rkB, const Quaternion &rkQ, bool shortestPath=false) |
Spherical quadratic interpolation. | |
Public Attributes | |
Real | w |
Real | x |
Real | y |
Real | z |
Static Public Attributes | |
static const Quaternion | IDENTITY |
static const Real | msEpsilon |
Cutoff for sine near zero. | |
static const Quaternion | ZERO |
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. | |
Implementation of a Quaternion, i.e.
a rotation around an axis. For more information about Quaternions and the theory behind it, we recommend reading: http://www.ogre3d.org/tikiwiki/Quaternion+and+Rotation+Primer and http://www.cprogramming.com/tutorial/3d/quaternions.html and http://www.gamedev.net/page/resources/_/reference/programming/math-and-physics/quaternions/quaternion-powers-r1095
Definition at line 56 of file OgreQuaternion.h.
Ogre::Quaternion::Quaternion | ( | ) |
Default constructor, initializes to identity rotation (aka 0°)
Definition at line 60 of file OgreQuaternion.h.
Referenced by Dot(), equals(), Exp(), Intermediate(), Inverse(), Log(), nlerp(), operator!=(), operator*(), operator*(), operator*, operator+(), operator-(), operator-(), operator<<, operator=(), operator==(), orientationEquals(), Slerp(), SlerpExtraSpins(), Squad(), swap(), and UnitInverse().
Ogre::Quaternion::Quaternion | ( | const Matrix3 & | rot | ) |
Construct a quaternion from a rotation matrix.
Definition at line 72 of file OgreQuaternion.h.
References FromRotationMatrix().
Construct a quaternion from an angle/axis.
Definition at line 77 of file OgreQuaternion.h.
References FromAngleAxis().
Ogre::Quaternion::Quaternion | ( | const Vector3 & | xaxis, |
const Vector3 & | yaxis, | ||
const Vector3 & | zaxis ) |
Construct a quaternion from 3 orthonormal local axes.
Definition at line 82 of file OgreQuaternion.h.
References FromAxes().
Ogre::Quaternion::Quaternion | ( | const Vector3 * | akAxis | ) |
Construct a quaternion from 3 orthonormal local axes.
Definition at line 87 of file OgreQuaternion.h.
References FromAxes().
Ogre::Quaternion::Quaternion | ( | Real * | valptr | ) |
Construct a quaternion from 4 manual w/x/y/z values.
Definition at line 92 of file OgreQuaternion.h.
References w.
Real Ogre::Quaternion::Dot | ( | const Quaternion & | rkQ | ) | const |
Returns the dot product of the quaternion.
References Quaternion().
Referenced by orientationEquals().
bool Ogre::Quaternion::equals | ( | const Quaternion & | rhs, |
const Radian & | tolerance ) const |
Equality with tolerance (tolerance is max angle difference)
References Quaternion().
Quaternion Ogre::Quaternion::Exp | ( | ) | const |
Apply to unit-length quaternion.
References Quaternion().
Setups the quaternion using the supplied vector, and "roll" around that vector by the specified radians.
Referenced by Quaternion(), Ogre::Vector3::getRotationTo(), and Ogre::Vector3::randomDeviant().
void Ogre::Quaternion::FromAxes | ( | const Vector3 * | akAxis | ) |
Constructs the quaternion using 3 axes, the axes are assumed to be orthonormal.
Referenced by Quaternion(), and Quaternion().
void Ogre::Quaternion::FromRotationMatrix | ( | const Matrix3 & | kRot | ) |
Referenced by Quaternion().
Radian Ogre::Quaternion::getPitch | ( | bool | reprojectAxis = true | ) | const |
Calculate the local pitch element of this quaternion.
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. The co-domain of the returned value is from -180 to 180 degrees. |
Radian Ogre::Quaternion::getRoll | ( | bool | reprojectAxis = true | ) | const |
Calculate the local roll element of this quaternion.
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. The co-domain of the returned value is from -180 to 180 degrees. |
Radian Ogre::Quaternion::getYaw | ( | bool | reprojectAxis = true | ) | const |
Calculate the local yaw element of this quaternion.
reprojectAxis | By default the method returns the 'intuitive' result that is, if you projected the local Y 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. The co-domain of the returned value is from -180 to 180 degrees. |
|
static |
Setup for spherical quadratic interpolation.
References Quaternion().
Quaternion Ogre::Quaternion::Inverse | ( | ) | const |
References Quaternion().
bool Ogre::Quaternion::isNaN | ( | ) | const |
Check whether this quaternion contains valid values.
Definition at line 320 of file OgreQuaternion.h.
References Ogre::Math::isNaN(), w, x, y, and z.
Quaternion Ogre::Quaternion::Log | ( | ) | const |
References Quaternion().
|
static |
Performs Normalised linear interpolation between two quaternions, and returns the result.
nlerp ( 0.0f, A, B ) = A nlerp ( 1.0f, A, B ) = B
References Quaternion().
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 191 of file OgreQuaternion.h.
References Quaternion(), and operator==().
Quaternion Ogre::Quaternion::operator* | ( | const Quaternion & | rkQ | ) | const |
References Quaternion().
Rotation of a vector by a quaternion.
Quaternion Ogre::Quaternion::operator* | ( | Real | fScalar | ) | const |
References Quaternion().
Quaternion Ogre::Quaternion::operator+ | ( | const Quaternion & | rkQ | ) | const |
References Quaternion().
Quaternion Ogre::Quaternion::operator- | ( | ) | const |
References Quaternion().
Quaternion Ogre::Quaternion::operator- | ( | const Quaternion & | rkQ | ) | const |
References Quaternion().
Quaternion & Ogre::Quaternion::operator= | ( | const Quaternion & | rkQ | ) |
Definition at line 171 of file OgreQuaternion.h.
References Quaternion(), w, x, y, and z.
bool Ogre::Quaternion::operator== | ( | const Quaternion & | rhs | ) | const |
Definition at line 186 of file OgreQuaternion.h.
References Quaternion(), w, x, y, and z.
Referenced by operator!=().
Real & Ogre::Quaternion::operator[] | ( | const size_t | i | ) |
Real Ogre::Quaternion::operator[] | ( | const size_t | i | ) | const |
bool Ogre::Quaternion::orientationEquals | ( | const Quaternion & | other, |
Real | tolerance = 1e-3 ) const |
Compare two quaternions which are assumed to be used as orientations.
Definition at line 254 of file OgreQuaternion.h.
References Quaternion(), and Dot().
Real * Ogre::Quaternion::ptr | ( | ) |
Pointer accessor for direct copying.
Definition at line 124 of file OgreQuaternion.h.
References w.
Referenced by Ogre::AnimableValue::setAsBaseValue().
const Real * Ogre::Quaternion::ptr | ( | ) | const |
|
static |
Performs Spherical linear interpolation between two quaternions, and returns the result.
Slerp ( 0.0f, A, B ) = A Slerp ( 1.0f, A, B ) = B
References Quaternion().
|
static |
References Quaternion().
|
static |
Spherical quadratic interpolation.
References Quaternion().
void Ogre::Quaternion::swap | ( | Quaternion & | other | ) |
Exchange the contents of this quaternion with another.
Definition at line 99 of file OgreQuaternion.h.
References Quaternion(), std::swap(), w, x, y, and z.
Definition at line 142 of file OgreQuaternion.h.
References ToAngleAxis().
Referenced by ToAngleAxis().
void Ogre::Quaternion::ToAxes | ( | Vector3 * | akAxis | ) | const |
Gets the 3 orthonormal axes defining the quaternion.
void Ogre::Quaternion::ToRotationMatrix | ( | Matrix3 & | kRot | ) | const |
Referenced by Ogre::Matrix4::Matrix4().
Quaternion Ogre::Quaternion::UnitInverse | ( | ) | const |
Apply to non-zero quaternion.
References Quaternion().
Vector3 Ogre::Quaternion::xAxis | ( | void | ) | const |
Returns the X orthonormal axis defining the quaternion.
Same as doing xAxis = Vector3::UNIT_X * this. Also called the local X-axis
Referenced by FromAxes(), and ToAxes().
Vector3 Ogre::Quaternion::yAxis | ( | void | ) | const |
Returns the Y orthonormal axis defining the quaternion.
Same as doing yAxis = Vector3::UNIT_Y * this. Also called the local Y-axis
Referenced by FromAxes(), and ToAxes().
Vector3 Ogre::Quaternion::zAxis | ( | void | ) | const |
Returns the Z orthonormal axis defining the quaternion.
Same as doing zAxis = Vector3::UNIT_Z * this. Also called the local Z-axis
Referenced by FromAxes(), and ToAxes().
|
friend |
References Quaternion(), and _OgreExport.
|
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 328 of file OgreQuaternion.h.
References Quaternion(), and _OgreExport.
|
static |
Definition at line 315 of file OgreQuaternion.h.
Referenced by Ogre::SceneManager::_setSkyBox(), Ogre::SceneManager::_setSkyDome(), Ogre::InstancedGeometry::addEntity(), Ogre::StaticGeometry::addEntity(), Ogre::Entity::attachObjectToBone(), Ogre::Bone::createChild(), Ogre::Node::createChild(), Ogre::Node::createChild(), Ogre::SceneNode::createChildSceneNode(), Ogre::SceneNode::createChildSceneNode(), Ogre::MeshManager::createCurvedIllusionPlane(), Ogre::SkeletonInstance::createTagPointOnBone(), Ogre::Vector3::getRotationTo(), Ogre::StringConverter::parseQuaternion(), Ogre::SceneManager::setSkyBox(), and Ogre::SceneManager::setSkyDome().
|
static |
Cutoff for sine near zero.
Definition at line 311 of file OgreQuaternion.h.
Real Ogre::Quaternion::w |
Definition at line 317 of file OgreQuaternion.h.
Referenced by Quaternion(), Quaternion(), Quaternion(), Ogre::Vector3::getRotationTo(), isNaN(), operator=(), operator==(), operator[](), operator[](), ptr(), ptr(), and swap().
Real Ogre::Quaternion::x |
Definition at line 317 of file OgreQuaternion.h.
Referenced by Quaternion(), Quaternion(), Ogre::Vector3::getRotationTo(), isNaN(), operator=(), operator==(), and swap().
Real Ogre::Quaternion::y |
Definition at line 317 of file OgreQuaternion.h.
Referenced by Quaternion(), Quaternion(), Ogre::Vector3::getRotationTo(), isNaN(), operator=(), operator==(), and swap().
Real Ogre::Quaternion::z |
Definition at line 317 of file OgreQuaternion.h.
Referenced by Quaternion(), Quaternion(), Ogre::Vector3::getRotationTo(), isNaN(), operator=(), operator==(), and swap().
|
static |
Definition at line 314 of file OgreQuaternion.h.