All Classes Namespaces Files Functions Variables Typedefs Friends Macros Modules
Public Member Functions | Static Public Member Functions | Public Attributes | Friends | List of all members
sdf::Quaternion Class Reference

A quaternion class. More...

#include <Types.hh>

Public Member Functions

 Quaternion ()
 Default Constructor. More...
 
 Quaternion (const Quaternion &_q)
 Copy constructor. More...
 
 Quaternion (const double &_roll, const double &_pitch, const double &_yaw)
 
 Quaternion (double _w, double _x, double _y, double _z)
 Constructor. More...
 
void Correct ()
 
Vector3 GetAsEuler () const
 Return the rotation in Euler angles. More...
 
Quaternion GetInverse () const
 Get the inverse of this quaternion. More...
 
void Normalize ()
 Normalize the quaternion. More...
 
Quaternion operator* (const Quaternion &_q) const
 Multiplication operator. More...
 
Vector3 operator* (const Vector3 &_v) const
 Vector3 multiplication 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...
 
void SetFromEuler (const Vector3 &_vec)
 Set the quaternion from Euler angles. More...
 

Static Public Member Functions

static Quaternion EulerToQuaternion (double _x, double _y, double _z)
 Convert euler angles to quatern. More...
 
static Quaternion EulerToQuaternion (const Vector3 &_vec)
 Convert euler angles to quatern. More...
 

Public Attributes

double w
 w data More...
 
double x
 x data More...
 
double y
 y data More...
 
double z
 z data More...
 

Friends

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

Detailed Description

A quaternion class.

Constructor & Destructor Documentation

sdf::Quaternion::Quaternion ( )
inline

Default Constructor.

sdf::Quaternion::Quaternion ( const Quaternion _q)
inline

Copy constructor.

Parameters
[in]_qQuaternion to copy
sdf::Quaternion::Quaternion ( const double &  _roll,
const double &  _pitch,
const double &  _yaw 
)
inline
sdf::Quaternion::Quaternion ( double  _w,
double  _x,
double  _y,
double  _z 
)
inline

Constructor.

Parameters
[in]_wW param
[in]_xX param
[in]_yY param
[in]_zZ param

Member Function Documentation

void sdf::Quaternion::Correct ( )
inline

References sdf::equal().

static Quaternion sdf::Quaternion::EulerToQuaternion ( double  _x,
double  _y,
double  _z 
)
inlinestatic

Convert euler angles to quatern.

Parameters
[in]_xrotation along x
[in]_yrotation along y
[in]_zrotation along z
static Quaternion sdf::Quaternion::EulerToQuaternion ( const Vector3 _vec)
inlinestatic

Convert euler angles to quatern.

Parameters
[in]_vecVector of Euler angles

References SetFromEuler().

Vector3 sdf::Quaternion::GetAsEuler ( ) const
inline

Return the rotation in Euler angles.

Returns
This quaternion as an Euler vector

References Normalize(), w, sdf::Vector3::x, x, sdf::Vector3::y, y, sdf::Vector3::z, and z.

Referenced by operator==().

Quaternion sdf::Quaternion::GetInverse ( ) const
inline

Get the inverse of this quaternion.

Returns
Inverse quarenion

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

Referenced by sdf::Pose::CoordPositionAdd().

void sdf::Quaternion::Normalize ( )
inline

Normalize the quaternion.

References sdf::equal().

Referenced by GetAsEuler().

Quaternion sdf::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.

Vector3 sdf::Quaternion::operator* ( const Vector3 _v) const
inline

Vector3 multiplication operator.

Parameters
[in]_vvector to multiply

References sdf::Vector3::Cross().

Quaternion& sdf::Quaternion::operator= ( const Quaternion _qt)
inline

Equal operator.

Parameters
[in]_qtQuaternion to copy

References w, x, y, and z.

bool sdf::Quaternion::operator== ( const Quaternion _qt) const
inline

Equal to operator.

Parameters
[in]_qtQuaternion for comparison
Returns
True if equal

References GetAsEuler().

Vector3 sdf::Quaternion::RotateVector ( const Vector3 _vec) const
inline

Rotate a vector using the quaternion.

Parameters
[in]_vecvector to rotate
Returns
the rotated vector

References sdf::Vector3::x, x, sdf::Vector3::y, y, sdf::Vector3::z, and z.

void sdf::Quaternion::SetFromEuler ( const Vector3 _vec)
inline

Set the quaternion from Euler angles.

Parameters
[in]_vecEuler angle

References sdf::Vector3::x, sdf::Vector3::y, and sdf::Vector3::z.

Referenced by EulerToQuaternion().

Friends And Related Function Documentation

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

Stream insertion operator.

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

Stream extraction operator.

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

Member Data Documentation

double sdf::Quaternion::w
double sdf::Quaternion::x
double sdf::Quaternion::y
double sdf::Quaternion::z

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