All Classes Namespaces Files Functions Variables Typedefs Friends Macros Pages
Public Member Functions | Static Public Member Functions | Static Public Attributes | Friends | List of all members
ignition::math::Quaternion< T > Class Template Reference

A quaternion class. More...

#include <ignition/math/Quaternion.hh>

Public Member Functions

 Quaternion ()
 Default Constructor. More...
 
 Quaternion (const T &_w, const T &_x, const T &_y, const T &_z)
 Constructor. More...
 
 Quaternion (const T &_roll, const T &_pitch, const T &_yaw)
 Constructor from Euler angles in radians. More...
 
 Quaternion (const Vector3< T > &_axis, const T &_angle)
 Constructor from axis angle. More...
 
 Quaternion (const Vector3< T > &_rpy)
 Constructor. More...
 
 Quaternion (const Quaternion< T > &_qt)
 Copy constructor. More...
 
 ~Quaternion ()
 Destructor. More...
 
void Axis (T _ax, T _ay, T _az, T _aa)
 Set the quaternion from an axis and angle. More...
 
void Axis (const Vector3< T > &_axis, T _a)
 Set the quaternion from an axis and angle. More...
 
void Correct ()
 Correct any nan. More...
 
Dot (const Quaternion< T > &_q) const
 Dot product. More...
 
void Euler (const Vector3< T > &_vec)
 Set the quaternion from Euler angles. More...
 
void Euler (T _roll, T _pitch, T _yaw)
 Set the quaternion from Euler angles. More...
 
Vector3< T > Euler () const
 Return the rotation in Euler angles. More...
 
Quaternion< T > Exp () const
 Return the exponent. More...
 
Quaternion< T > Inverse () const
 Get the inverse of this quaternion. More...
 
void Invert ()
 Invert the quaternion. More...
 
bool IsFinite () const
 See if a quatern is finite (e.g., not nan) More...
 
Quaternion< T > Log () const
 Return the logarithm. More...
 
void Normalize ()
 Normalize the quaternion. More...
 
bool operator!= (const Quaternion< T > &_qt) const
 Not equal to operator. More...
 
Quaternion< T > operator* (const Quaternion< T > &_q) const
 Multiplication operator. More...
 
Quaternion< T > operator* (const T &_f) const
 Multiplication operator. More...
 
Vector3< T > operator* (const Vector3< T > &_v) const
 Vector3 multiplication operator. More...
 
Quaternion< T > operator*= (const Quaternion< T > &qt)
 Multiplication operator. More...
 
Quaternion< T > operator+ (const Quaternion< T > &_qt) const
 Addition operator. More...
 
Quaternion< T > operator+= (const Quaternion< T > &_qt)
 Addition operator. More...
 
Quaternion< T > operator- (const Quaternion< T > &_qt) const
 Substraction operator. More...
 
Quaternion< T > operator- () const
 Unary minus operator. More...
 
Quaternion< T > operator-= (const Quaternion< T > &_qt)
 Substraction operator. More...
 
Quaternion< T > & operator= (const Quaternion< T > &_qt)
 Equal operator. More...
 
bool operator== (const Quaternion< T > &_qt) const
 Equal to operator. More...
 
Pitch () const
 Get the Euler pitch angle in radians. More...
 
Roll () const
 Get the Euler roll angle in radians. More...
 
Vector3< T > RotateVector (const Vector3< T > &_vec) const
 Rotate a vector using the quaternion. More...
 
Vector3< T > RotateVectorReverse (Vector3< T > _vec) const
 Do the reverse rotation of a vector by this quaternion. More...
 
void Round (int _precision)
 Round all values to _precision decimal places. More...
 
void Scale (T _scale)
 Scale a Quaternion<T>ion. More...
 
void Set (T _w, T _x, T _y, T _z)
 Set this quaternion from 4 floating numbers. More...
 
void ToAxis (Vector3< T > &_axis, T &_angle) const
 Return rotation as axis and angle. More...
 
const T & W () const
 Get the w component. More...
 
T & W ()
 Get a mutable w component. More...
 
void W (T _v)
 Set the w component. More...
 
const T & X () const
 Get the x component. More...
 
T & X ()
 Get a mutable x component. More...
 
void X (T _v)
 Set the x component. More...
 
Vector3< T > XAxis () const
 Return the X axis. More...
 
const T & Y () const
 Get the y component. More...
 
T & Y ()
 Get a mutable y component. More...
 
void Y (T _v)
 Set the y component. More...
 
Yaw () const
 Get the Euler yaw angle in radians. More...
 
Vector3< T > YAxis () const
 Return the Y axis. More...
 
const T & Z () const
 Get the z component. More...
 
T & Z ()
 Get a mutable z component. More...
 
void Z (T _v)
 Set the z component. More...
 
Vector3< T > ZAxis () const
 Return the Z axis. More...
 

Static Public Member Functions

static Quaternion< T > EulerToQuaternion (const Vector3< T > &_vec)
 Convert euler angles to quatern. More...
 
static Quaternion< T > EulerToQuaternion (T _x, T _y, T _z)
 Convert euler angles to quatern. More...
 
static Quaternion< T > Slerp (T _fT, const Quaternion< T > &_rkP, const Quaternion< T > &_rkQ, bool _shortestPath=false)
 Spherical linear interpolation between 2 quaternions, given the ends and an interpolation parameter between 0 and 1. More...
 
static Quaternion< T > Squad (T _fT, const Quaternion< T > &_rkP, const Quaternion< T > &_rkA, const Quaternion< T > &_rkB, const Quaternion< T > &_rkQ, bool _shortestPath=false)
 Spherical quadratic interpolation given the ends and an interpolation parameter between 0 and 1. More...
 

Static Public Attributes

static const Quaternion Identity
 math::Quaternion(1, 0, 0, 1) More...
 

Friends

std::ostream & operator<< (std::ostream &_out, const ignition::math::Quaternion< T > &_q)
 Stream insertion operator. More...
 
std::istream & operator>> (std::istream &_in, ignition::math::Quaternion< T > &_q)
 Stream extraction operator. More...
 

Detailed Description

template<typename T>
class ignition::math::Quaternion< T >

A quaternion class.

Constructor & Destructor Documentation

template<typename T>
ignition::math::Quaternion< T >::Quaternion ( )
inline

Default Constructor.

template<typename T>
ignition::math::Quaternion< T >::Quaternion ( const T &  _w,
const T &  _x,
const T &  _y,
const T &  _z 
)
inline

Constructor.

Parameters
[in]_wW param
[in]_xX param
[in]_yY param
[in]_zZ param
template<typename T>
ignition::math::Quaternion< T >::Quaternion ( const T &  _roll,
const T &  _pitch,
const T &  _yaw 
)
inline

Constructor from Euler angles in radians.

Parameters
[in]_rollroll
[in]_pitchpitch
[in]_yawyaw

References ignition::math::Quaternion< T >::Euler().

template<typename T>
ignition::math::Quaternion< T >::Quaternion ( const Vector3< T > &  _axis,
const T &  _angle 
)
inline

Constructor from axis angle.

Parameters
[in]_axisthe rotation axis
[in]_anglethe rotation angle in radians

References ignition::math::Quaternion< T >::Axis().

template<typename T>
ignition::math::Quaternion< T >::Quaternion ( const Vector3< T > &  _rpy)
inline

Constructor.

Parameters
[in]_rpyeuler angles

References ignition::math::Quaternion< T >::Euler().

template<typename T>
ignition::math::Quaternion< T >::Quaternion ( const Quaternion< T > &  _qt)
inline

Copy constructor.

Parameters
qtQuaternion<T> to copy
template<typename T>
ignition::math::Quaternion< T >::~Quaternion ( )
inline

Destructor.

Member Function Documentation

template<typename T>
void ignition::math::Quaternion< T >::Axis ( _ax,
_ay,
_az,
_aa 
)
inline

Set the quaternion from an axis and angle.

Parameters
[in]_xX axis
[in]_yY axis
[in]_zZ axis
[in]_aAngle in radians

References ignition::math::Quaternion< T >::Normalize().

Referenced by ignition::math::Quaternion< T >::Axis(), ignition::math::Quaternion< T >::Quaternion(), and ignition::math::Quaternion< T >::Scale().

template<typename T>
void ignition::math::Quaternion< T >::Axis ( const Vector3< T > &  _axis,
_a 
)
inline

Set the quaternion from an axis and angle.

Parameters
[in]_axisAxis
[in]_aAngle in radians

References ignition::math::Quaternion< T >::Axis(), ignition::math::Vector3< T >::X(), ignition::math::Vector3< T >::Y(), and ignition::math::Vector3< T >::Z().

template<typename T>
void ignition::math::Quaternion< T >::Correct ( )
inline

Correct any nan.

References ignition::math::equal().

template<typename T>
T ignition::math::Quaternion< T >::Dot ( const Quaternion< T > &  _q) const
inline

Dot product.

Parameters
[in]_qthe other quaternion
Returns
the product

Referenced by ignition::math::Quaternion< T >::Slerp().

template<typename T>
void ignition::math::Quaternion< T >::Euler ( const Vector3< T > &  _vec)
inline

Set the quaternion from Euler angles.

The order of operations are roll, pitch, yaw.

Parameters
[in]vecEuler angle

References ignition::math::Quaternion< T >::Euler(), ignition::math::Vector3< T >::X(), ignition::math::Vector3< T >::Y(), and ignition::math::Vector3< T >::Z().

Referenced by ignition::math::Quaternion< T >::EulerToQuaternion().

template<typename T>
void ignition::math::Quaternion< T >::Euler ( _roll,
_pitch,
_yaw 
)
inline

Set the quaternion from Euler angles.

Parameters
[in]_rollRoll angle (radians).
[in]_pitchRoll angle (radians).
[in]_yawRoll angle (radians).

References ignition::math::Quaternion< T >::Normalize().

template<typename T>
Vector3<T> ignition::math::Quaternion< T >::Euler ( ) const
inline
template<typename T>
static Quaternion<T> ignition::math::Quaternion< T >::EulerToQuaternion ( const Vector3< T > &  _vec)
inlinestatic

Convert euler angles to quatern.

Parameters
[in]

References ignition::math::Quaternion< T >::Euler().

Referenced by ignition::math::Quaternion< T >::EulerToQuaternion().

template<typename T>
static Quaternion<T> ignition::math::Quaternion< T >::EulerToQuaternion ( _x,
_y,
_z 
)
inlinestatic

Convert euler angles to quatern.

Parameters
[in]_xrotation along x
[in]_yrotation along y
[in]_zrotation along z

References ignition::math::Quaternion< T >::EulerToQuaternion().

template<typename T>
Quaternion<T> ignition::math::Quaternion< T >::Exp ( ) const
inline

Return the exponent.

Returns
the exp
template<typename T>
Quaternion<T> ignition::math::Quaternion< T >::Inverse ( ) const
inline
template<typename T>
void ignition::math::Quaternion< T >::Invert ( )
inline

Invert the quaternion.

References ignition::math::Quaternion< T >::Normalize().

template<typename T>
bool ignition::math::Quaternion< T >::IsFinite ( ) const
inline

See if a quatern is finite (e.g., not nan)

Returns
True if quatern is finite
template<typename T>
Quaternion<T> ignition::math::Quaternion< T >::Log ( ) const
inline

Return the logarithm.

Returns
the log
template<typename T>
void ignition::math::Quaternion< T >::Normalize ( )
inline
template<typename T>
bool ignition::math::Quaternion< T >::operator!= ( const Quaternion< T > &  _qt) const
inline

Not equal to operator.

Parameters
[in]_qtQuaternion<T> for comparison
Returns
True if not equal

References ignition::math::equal().

template<typename T>
Quaternion<T> ignition::math::Quaternion< T >::operator* ( const Quaternion< T > &  _q) const
inline

Multiplication operator.

Parameters
[in]_qtQuaternion<T> for multiplication
Returns
This quaternion multiplied by the parameter
template<typename T>
Quaternion<T> ignition::math::Quaternion< T >::operator* ( const T &  _f) const
inline

Multiplication operator.

Parameters
[in]_ffactor
Returns
quaternion multiplied by _f
template<typename T>
Vector3<T> ignition::math::Quaternion< T >::operator* ( const Vector3< T > &  _v) const
inline

Vector3 multiplication operator.

Parameters
[in]_vvector to multiply

References ignition::math::Vector3< T >::Cross().

template<typename T>
Quaternion<T> ignition::math::Quaternion< T >::operator*= ( const Quaternion< T > &  qt)
inline

Multiplication operator.

Parameters
[in]_qtQuaternion<T> for multiplication
Returns
This quatern multiplied by the parameter
template<typename T>
Quaternion<T> ignition::math::Quaternion< T >::operator+ ( const Quaternion< T > &  _qt) const
inline

Addition operator.

Parameters
[in]_qtquaternion for addition
Returns
this quaternion + _qt
template<typename T>
Quaternion<T> ignition::math::Quaternion< T >::operator+= ( const Quaternion< T > &  _qt)
inline

Addition operator.

Parameters
[in]_qtquaternion for addition
Returns
this quaternion + qt
template<typename T>
Quaternion<T> ignition::math::Quaternion< T >::operator- ( const Quaternion< T > &  _qt) const
inline

Substraction operator.

Parameters
[in]_qtquaternion to substract
Returns
this quaternion - _qt
template<typename T>
Quaternion<T> ignition::math::Quaternion< T >::operator- ( ) const
inline

Unary minus operator.

Returns
negates each component of the quaternion
template<typename T>
Quaternion<T> ignition::math::Quaternion< T >::operator-= ( const Quaternion< T > &  _qt)
inline

Substraction operator.

Parameters
[in]_qtQuaternion<T> for substraction
Returns
This quatern - qt
template<typename T>
Quaternion<T>& ignition::math::Quaternion< T >::operator= ( const Quaternion< T > &  _qt)
inline

Equal operator.

Parameters
[in]_qtQuaternion<T> to copy
template<typename T>
bool ignition::math::Quaternion< T >::operator== ( const Quaternion< T > &  _qt) const
inline

Equal to operator.

Parameters
[in]_qtQuaternion<T> for comparison
Returns
True if equal

References ignition::math::equal().

template<typename T>
T ignition::math::Quaternion< T >::Pitch ( ) const
inline

Get the Euler pitch angle in radians.

Returns
the pitch

References ignition::math::Quaternion< T >::Euler().

template<typename T>
T ignition::math::Quaternion< T >::Roll ( ) const
inline

Get the Euler roll angle in radians.

Returns
the roll

References ignition::math::Quaternion< T >::Euler().

template<typename T>
Vector3<T> ignition::math::Quaternion< T >::RotateVector ( const Vector3< T > &  _vec) const
inline

Rotate a vector using the quaternion.

Parameters
[in]_vecvector to rotate
Returns
the rotated vector

References ignition::math::Quaternion< T >::Inverse(), ignition::math::Vector3< T >::X(), ignition::math::Vector3< T >::Y(), and ignition::math::Vector3< T >::Z().

template<typename T>
Vector3<T> ignition::math::Quaternion< T >::RotateVectorReverse ( Vector3< T >  _vec) const
inline

Do the reverse rotation of a vector by this quaternion.

Parameters
[in]_vecthe vector
Returns
the

References ignition::math::Quaternion< T >::Inverse(), ignition::math::Vector3< T >::X(), ignition::math::Vector3< T >::Y(), and ignition::math::Vector3< T >::Z().

template<typename T>
void ignition::math::Quaternion< T >::Round ( int  _precision)
inline

Round all values to _precision decimal places.

Parameters
[in]_precisionthe precision

References ignition::math::precision().

template<typename T>
void ignition::math::Quaternion< T >::Scale ( _scale)
inline
template<typename T>
void ignition::math::Quaternion< T >::Set ( _w,
_x,
_y,
_z 
)
inline

Set this quaternion from 4 floating numbers.

Parameters
[in]_uu
[in]_xx
[in]_yy
[in]_zz
template<typename T>
static Quaternion<T> ignition::math::Quaternion< T >::Slerp ( _fT,
const Quaternion< T > &  _rkP,
const Quaternion< T > &  _rkQ,
bool  _shortestPath = false 
)
inlinestatic

Spherical linear interpolation between 2 quaternions, given the ends and an interpolation parameter between 0 and 1.

Parameters
[in]_ftthe interpolation parameter
[in]_rkPthe beginning quaternion
[in]_rkQthe end quaternion
[in]_shortestPathwhen true, the rotation may be inverted to get to minimize rotation

References ignition::math::Quaternion< T >::Dot(), and ignition::math::Quaternion< T >::Normalize().

Referenced by ignition::math::OnePoleQuaternion::Process(), and ignition::math::Quaternion< T >::Squad().

template<typename T>
static Quaternion<T> ignition::math::Quaternion< T >::Squad ( _fT,
const Quaternion< T > &  _rkP,
const Quaternion< T > &  _rkA,
const Quaternion< T > &  _rkB,
const Quaternion< T > &  _rkQ,
bool  _shortestPath = false 
)
inlinestatic

Spherical quadratic interpolation given the ends and an interpolation parameter between 0 and 1.

Parameters
[in]_ftthe interpolation parameter
[in]_rkPthe beginning quaternion
[in]_rkAfirst intermediate quaternion
[in]_rkBsecond intermediate quaternion
[in]_rkQthe end quaternion
[in]_shortestPathwhen true, the rotation may be inverted to get to minimize rotation

References ignition::math::Quaternion< T >::Slerp().

template<typename T>
void ignition::math::Quaternion< T >::ToAxis ( Vector3< T > &  _axis,
T &  _angle 
) const
inline

Return rotation as axis and angle.

Parameters
[in]_axisrotation axis
[in]_angleccw angle in radians

References ignition::math::Vector3< T >::Set().

Referenced by ignition::math::Quaternion< T >::Scale().

template<typename T>
const T& ignition::math::Quaternion< T >::W ( ) const
inline
template<typename T>
T& ignition::math::Quaternion< T >::W ( )
inline

Get a mutable w component.

Returns
The w quaternion component.
template<typename T>
void ignition::math::Quaternion< T >::W ( _v)
inline

Set the w component.

Parameters
[in]_vThe new value for the w quaternion component.
template<typename T>
const T& ignition::math::Quaternion< T >::X ( ) const
inline
template<typename T>
T& ignition::math::Quaternion< T >::X ( )
inline

Get a mutable x component.

Returns
The x quaternion component.
template<typename T>
void ignition::math::Quaternion< T >::X ( _v)
inline

Set the x component.

Parameters
[in]_vThe new value for the x quaternion component.
template<typename T>
Vector3<T> ignition::math::Quaternion< T >::XAxis ( ) const
inline

Return the X axis.

Returns
the vector
template<typename T>
const T& ignition::math::Quaternion< T >::Y ( ) const
inline
template<typename T>
T& ignition::math::Quaternion< T >::Y ( )
inline

Get a mutable y component.

Returns
The y quaternion component.
template<typename T>
void ignition::math::Quaternion< T >::Y ( _v)
inline

Set the y component.

Parameters
[in]_vThe new value for the y quaternion component.
template<typename T>
T ignition::math::Quaternion< T >::Yaw ( ) const
inline

Get the Euler yaw angle in radians.

Returns
the yaw

References ignition::math::Quaternion< T >::Euler().

template<typename T>
Vector3<T> ignition::math::Quaternion< T >::YAxis ( ) const
inline

Return the Y axis.

Returns
the vector
template<typename T>
const T& ignition::math::Quaternion< T >::Z ( ) const
inline
template<typename T>
T& ignition::math::Quaternion< T >::Z ( )
inline

Get a mutable z component.

Returns
The z quaternion component.
template<typename T>
void ignition::math::Quaternion< T >::Z ( _v)
inline

Set the z component.

Parameters
[in]_vThe new value for the z quaternion component.
template<typename T>
Vector3<T> ignition::math::Quaternion< T >::ZAxis ( ) const
inline

Return the Z axis.

Returns
the vector

Friends And Related Function Documentation

template<typename T>
std::ostream& operator<< ( std::ostream &  _out,
const ignition::math::Quaternion< T > &  _q 
)
friend

Stream insertion operator.

Parameters
[in]_outoutput stream
[in]_qquaternion to output
Returns
the stream
template<typename T>
std::istream& operator>> ( std::istream &  _in,
ignition::math::Quaternion< T > &  _q 
)
friend

Stream extraction operator.

Parameters
[in]_ininput stream
[in]_qQuaternion<T> to read values into
Returns
The istream

Member Data Documentation

template<typename T>
const Quaternion< T > ignition::math::Quaternion< T >::Identity
static

math::Quaternion(1, 0, 0, 1)

Referenced by ignition::math::Pose3< T >::Reset().


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