All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
Public Member Functions | Static Public Member Functions | Public Attributes | Friends | List of all members
gazebo::math::Quaternion Class Reference

A quaternion class. More...

#include <math/gzmath.hh>

Public Member Functions

 Quaternion ()
 Default Constructor. More...
 
 Quaternion (const double &_w, const double &_x, const double &_y, const double &_z)
 Constructor. More...
 
 Quaternion (const double &_roll, const double &_pitch, const double &_yaw)
 Constructor from Euler angles in radians. More...
 
 Quaternion (const Vector3 &_axis, const double &_angle)
 Constructor from axis angle. More...
 
 Quaternion (const Vector3 &_rpy)
 Constructor. More...
 
 Quaternion (const Quaternion &_qt)
 Copy constructor. More...
 
 ~Quaternion ()
 Destructor. More...
 
void Correct ()
 Correct any nan. More...
 
double Dot (const Quaternion &_q) const
 Dot product. More...
 
void GetAsAxis (Vector3 &_axis, double &_angle) const
 Return rotation as axis and angle. More...
 
Vector3 GetAsEuler () const
 Return the rotation in Euler angles. More...
 
Matrix3 GetAsMatrix3 () const
 Get the quaternion as a 3x3 matrix. More...
 
Matrix4 GetAsMatrix4 () const
 Get the quaternion as a 4x4 matrix. More...
 
Quaternion GetExp () const
 Return the exponent. More...
 
Quaternion GetInverse () const
 Get the inverse of this quaternion. More...
 
Quaternion GetLog () const
 Return the logarithm. More...
 
double GetPitch ()
 Get the Euler pitch angle in radians. More...
 
double GetRoll ()
 Get the Euler roll angle in radians. More...
 
Vector3 GetXAxis () const
 Return the X axis. More...
 
double GetYaw ()
 Get the Euler yaw angle in radians. More...
 
Vector3 GetYAxis () const
 Return the Y axis. More...
 
Vector3 GetZAxis () const
 Return the Z axis. More...
 
void Invert ()
 Invert the quaternion. More...
 
bool IsFinite () const
 See if a quatern is finite (e.g., not nan) More...
 
void Normalize ()
 Normalize the quaternion. More...
 
bool operator!= (const Quaternion &_qt) const
 Not equal to operator. More...
 
Quaternion operator* (const Quaternion &_q) const
 Multiplication operator. More...
 
Quaternion operator* (const double &_f) const
 Multiplication operator. More...
 
Vector3 operator* (const Vector3 &_v) const
 Vector3 multiplication operator. More...
 
Quaternion operator*= (const Quaternion &qt)
 Multiplication operator. More...
 
Quaternion operator+ (const Quaternion &_qt) const
 Addition operator. More...
 
Quaternion operator+= (const Quaternion &_qt)
 Addition operator. More...
 
Quaternion operator- (const Quaternion &_qt) const
 Substraction operator. More...
 
Quaternion operator- () const
 Unary minus operator. More...
 
Quaternion operator-= (const Quaternion &_qt)
 Substraction operator. More...
 
Quaternionoperator= (const Quaternion &_qt)
 Equal operator. More...
 
bool operator== (const Quaternion &_qt) const
 Equal to operator. More...
 
Vector3 RotateVector (const Vector3 &_vec) const
 Rotate a vector using the quaternion. More...
 
Vector3 RotateVectorReverse (Vector3 _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 (double _scale)
 Scale a Quaternionion. More...
 
void Set (double _u, double _x, double _y, double _z)
 Set this quaternion from 4 floating numbers. More...
 
void SetFromAxis (double _x, double _y, double _z, double _a)
 Set the quaternion from an axis and angle. More...
 
void SetFromAxis (const Vector3 &_axis, double _a)
 Set the quaternion from an axis and angle. More...
 
void SetFromEuler (const Vector3 &_vec)
 Set the quaternion from Euler angles. More...
 
void SetFromEuler (double _roll, double _pitch, double _yaw)
 Set the quaternion from Euler angles. More...
 
void SetToIdentity ()
 Set the quatern to the identity. More...
 

Static Public Member Functions

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

Public Attributes

double w
 Attributes of the quaternion. More...
 
double x
 Attributes of the quaternion. More...
 
double y
 Attributes of the quaternion. More...
 
double z
 Attributes of the quaternion. More...
 

Friends

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

Detailed Description

A quaternion class.

Constructor & Destructor Documentation

gazebo::math::Quaternion::Quaternion ( )

Default Constructor.

gazebo::math::Quaternion::Quaternion ( const double &  _w,
const double &  _x,
const double &  _y,
const double &  _z 
)

Constructor.

Parameters
[in]_wW param
[in]_xX param
[in]_yY param
[in]_zZ param
gazebo::math::Quaternion::Quaternion ( const double &  _roll,
const double &  _pitch,
const double &  _yaw 
)

Constructor from Euler angles in radians.

Parameters
[in]_rollroll
[in]_pitchpitch
[in]_yawyaw
gazebo::math::Quaternion::Quaternion ( const Vector3 _axis,
const double &  _angle 
)

Constructor from axis angle.

Parameters
[in]_axisthe rotation axis
[in]_anglethe rotation angle in radians
gazebo::math::Quaternion::Quaternion ( const Vector3 _rpy)

Constructor.

Parameters
[in]_rpyeuler angles
gazebo::math::Quaternion::Quaternion ( const Quaternion _qt)

Copy constructor.

Parameters
qtQuaternion to copy
gazebo::math::Quaternion::~Quaternion ( )

Destructor.

Member Function Documentation

void gazebo::math::Quaternion::Correct ( )
inline

Correct any nan.

References gazebo::math::equal().

double gazebo::math::Quaternion::Dot ( const Quaternion _q) const

Dot product.

Parameters
[in]_qthe other quaternion
Returns
the product
static Quaternion gazebo::math::Quaternion::EulerToQuaternion ( const Vector3 _vec)
static

Convert euler angles to quatern.

Parameters
[in]
static Quaternion gazebo::math::Quaternion::EulerToQuaternion ( double  _x,
double  _y,
double  _z 
)
static

Convert euler angles to quatern.

Parameters
[in]_xrotation along x
[in]_yrotation along y
[in]_zrotation along z
void gazebo::math::Quaternion::GetAsAxis ( Vector3 _axis,
double &  _angle 
) const

Return rotation as axis and angle.

Parameters
[in]_axisrotation axis
[in]_angleccw angle in radians
Vector3 gazebo::math::Quaternion::GetAsEuler ( ) const

Return the rotation in Euler angles.

Returns
This quaternion as an Euler vector
Matrix3 gazebo::math::Quaternion::GetAsMatrix3 ( ) const

Get the quaternion as a 3x3 matrix.

Matrix4 gazebo::math::Quaternion::GetAsMatrix4 ( ) const

Get the quaternion as a 4x4 matrix.

Returns
a 4x4 matrix
Quaternion gazebo::math::Quaternion::GetExp ( ) const

Return the exponent.

Returns
the exp
Quaternion gazebo::math::Quaternion::GetInverse ( ) const
inline

Get the inverse of this quaternion.

Returns
Inverse quarenion

References gazebo::math::equal(), w, x, y, and z.

Referenced by gazebo::math::Pose::CoordPositionSub(), and gazebo::math::Pose::CoordRotationSub().

Quaternion gazebo::math::Quaternion::GetLog ( ) const

Return the logarithm.

Returns
the log
double gazebo::math::Quaternion::GetPitch ( )

Get the Euler pitch angle in radians.

Returns
the pitch
double gazebo::math::Quaternion::GetRoll ( )

Get the Euler roll angle in radians.

Returns
the roll
Vector3 gazebo::math::Quaternion::GetXAxis ( ) const

Return the X axis.

Returns
the vector
double gazebo::math::Quaternion::GetYaw ( )

Get the Euler yaw angle in radians.

Returns
the yaw
Vector3 gazebo::math::Quaternion::GetYAxis ( ) const

Return the Y axis.

Returns
the vector
Vector3 gazebo::math::Quaternion::GetZAxis ( ) const

Return the Z axis.

Returns
the vector
void gazebo::math::Quaternion::Invert ( )

Invert the quaternion.

bool gazebo::math::Quaternion::IsFinite ( ) const

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

Returns
True if quatern is finite
void gazebo::math::Quaternion::Normalize ( )

Normalize the quaternion.

Referenced by gazebo::math::Pose::CoordRotationSub().

bool gazebo::math::Quaternion::operator!= ( const Quaternion _qt) const

Not equal to operator.

Parameters
[in]_qtQuaternion for comparison
Returns
True if not equal
Quaternion gazebo::math::Quaternion::operator* ( const Quaternion _q) const
inline

Multiplication operator.

Parameters
[in]_qtQuaternion for multiplication
Returns
This quaternion multiplied by the parameter

References w, x, y, and z.

Quaternion gazebo::math::Quaternion::operator* ( const double &  _f) const

Multiplication operator.

Parameters
[in]_ffactor
Returns
quaternion multiplied by _f
Vector3 gazebo::math::Quaternion::operator* ( const Vector3 _v) const

Vector3 multiplication operator.

Parameters
[in]_vvector to multiply
Quaternion gazebo::math::Quaternion::operator*= ( const Quaternion qt)

Multiplication operator.

Parameters
[in]_qtQuaternion for multiplication
Returns
This quatern multiplied by the parameter
Quaternion gazebo::math::Quaternion::operator+ ( const Quaternion _qt) const

Addition operator.

Parameters
[in]_qtquaternion for addition
Returns
this quaternion + _qt
Quaternion gazebo::math::Quaternion::operator+= ( const Quaternion _qt)

Addition operator.

Parameters
[in]_qtquaternion for addition
Returns
this quaternion + qt
Quaternion gazebo::math::Quaternion::operator- ( const Quaternion _qt) const

Substraction operator.

Parameters
[in]_qtquaternion to substract
Returns
this quaternion - _qt
Quaternion gazebo::math::Quaternion::operator- ( ) const

Unary minus operator.

Returns
negates each component of the quaternion
Quaternion gazebo::math::Quaternion::operator-= ( const Quaternion _qt)

Substraction operator.

Parameters
[in]_qtQuaternion for substraction
Returns
This quatern - qt
Quaternion& gazebo::math::Quaternion::operator= ( const Quaternion _qt)

Equal operator.

Parameters
[in]_qtQuaternion to copy
bool gazebo::math::Quaternion::operator== ( const Quaternion _qt) const

Equal to operator.

Parameters
[in]_qtQuaternion for comparison
Returns
True if equal
Vector3 gazebo::math::Quaternion::RotateVector ( const Vector3 _vec) const
inline

Rotate a vector using the quaternion.

Parameters
[in]_vecvector to rotate
Returns
the rotated vector

References gazebo::math::Vector3::x, x, gazebo::math::Vector3::y, y, gazebo::math::Vector3::z, and z.

Vector3 gazebo::math::Quaternion::RotateVectorReverse ( Vector3  _vec) const

Do the reverse rotation of a vector by this quaternion.

Parameters
[in]_vecthe vector
Returns
the
void gazebo::math::Quaternion::Round ( int  _precision)

Round all values to _precision decimal places.

Parameters
[in]_precisionthe precision
void gazebo::math::Quaternion::Scale ( double  _scale)

Scale a Quaternionion.

Parameters
[in]_scaleAmount to scale this rotation
void gazebo::math::Quaternion::Set ( double  _u,
double  _x,
double  _y,
double  _z 
)

Set this quaternion from 4 floating numbers.

Parameters
[in]_uu
[in]_xx
[in]_yy
[in]_zz
void gazebo::math::Quaternion::SetFromAxis ( double  _x,
double  _y,
double  _z,
double  _a 
)

Set the quaternion from an axis and angle.

Parameters
[in]_xX axis
[in]_yY axis
[in]_zZ axis
[in]_aAngle in radians
void gazebo::math::Quaternion::SetFromAxis ( const Vector3 _axis,
double  _a 
)

Set the quaternion from an axis and angle.

Parameters
[in]_axisAxis
[in]_aAngle in radians
void gazebo::math::Quaternion::SetFromEuler ( const Vector3 _vec)

Set the quaternion from Euler angles.

The order of operations are roll, pitch, yaw.

Parameters
[in]vecEuler angle
void gazebo::math::Quaternion::SetFromEuler ( double  _roll,
double  _pitch,
double  _yaw 
)

Set the quaternion from Euler angles.

Parameters
[in]_rollRoll angle (radians).
[in]_pitchRoll angle (radians).
[in]_yawRoll angle (radians).
void gazebo::math::Quaternion::SetToIdentity ( )

Set the quatern to the identity.

static Quaternion gazebo::math::Quaternion::Slerp ( double  _fT,
const Quaternion _rkP,
const Quaternion _rkQ,
bool  _shortestPath = false 
)
static

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

Referenced by gazebo::math::OnePoleQuaternion::Process().

static Quaternion gazebo::math::Quaternion::Squad ( double  _fT,
const Quaternion _rkP,
const Quaternion _rkA,
const Quaternion _rkB,
const Quaternion _rkQ,
bool  _shortestPath = false 
)
static

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

Friends And Related Function Documentation

std::ostream& operator<< ( std::ostream &  _out,
const gazebo::math::Quaternion _q 
)
friend

Stream insertion operator.

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

Stream extraction operator.

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

Member Data Documentation

double gazebo::math::Quaternion::w
double gazebo::math::Quaternion::x
double gazebo::math::Quaternion::y
double gazebo::math::Quaternion::z

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