octomap 1.5.0
octomath::Quaternion Class Reference

This class represents a Quaternion. More...

Public Member Functions

Quaternion inv () const
 Inversion.
Quaternioninv_IP ()
 Inversion.
float norm () const
Quaternionnormalize ()
Quaternion normalized () const
const float & operator() (unsigned int i) const
float & operator() (unsigned int i)
Quaternion operator* (const Quaternion &other) const
 Quaternion multiplication.
Quaternion operator* (const Vector3 &v) const
 Quaternion multiplication with extended vector.
void operator/= (float x)
Quaternionoperator= (const Quaternion &other)
bool operator== (const Quaternion &other) const
 Quaternion (const Quaternion &other)
 Copy constructor.
 Quaternion (const Vector3 &other)
 Constructor.
 Quaternion (double roll, double pitch, double yaw)
 Constructor from Euler angles.
 Quaternion ()
 Default constructor.
 Quaternion (const Vector3 &axis, double angle)
 Constructs a Unit Quaternion from a rotation angle and axis.
 Quaternion (float u, float x, float y, float z)
 Constructor.
std::istream & read (std::istream &s)
std::istream & readBinary (std::istream &s)
Vector3 rotate (const Vector3 &v) const
 Rotate a vector.
Vector3 toEuler () const
 Conversion to Euler angles.
void toRotMatrix (std::vector< double > &rot_matrix_3_3) const
float & u ()
const float & u () const
std::ostream & write (std::ostream &s) const
std::ostream & writeBinary (std::ostream &s) const
const float & x () const
float & x ()
float & y ()
const float & y () const
float & z ()
const float & z () const

Protected Attributes

float data [4]

Friends

Quaternion operator* (const Vector3 &v, const Quaternion &q)
 Quaternion multiplication with extended vector.

Detailed Description

This class represents a Quaternion.

The Unit Quaternion is one possible representation of the attitude of an object in tree-dimensional space.

This Quaternion class is implemented according to Diebel, James. Representing Attitude: Euler Angle, Unit Quaternions, and Rotation Vectors. Stanford University. 2006. - Technical Report.


Constructor & Destructor Documentation

octomath::Quaternion::Quaternion ( ) [inline]

Default constructor.

Constructs the (1,0,0,0) Unit Quaternion representing the identity rotation.

References u(), x(), y(), and z().

Referenced by inv(), operator*(), and Quaternion().

octomath::Quaternion::Quaternion ( const Quaternion other)

Copy constructor.

References data.

octomath::Quaternion::Quaternion ( float  u,
float  x,
float  y,
float  z 
)

Constructor.

Constructs a Quaternion from four single values

References u(), x(), y(), and z().

octomath::Quaternion::Quaternion ( const Vector3 other)

Constructor.

Parameters:
othera vector containing euler angles

References operator=(), octomath::Vector3::pitch(), Quaternion(), octomath::Vector3::roll(), and octomath::Vector3::yaw().

octomath::Quaternion::Quaternion ( double  roll,
double  pitch,
double  yaw 
)

Constructor from Euler angles.

Constructs a Unit Quaternion from Euler angles / Tait Bryan angles (in radians) according to the 1-2-3 convention.

Parameters:
rollphi/roll angle (rotation about x-axis)
pitchtheta/pitch angle (rotation about y-axis)
yawpsi/yaw angle (rotation about z-axis)

References u(), x(), y(), and z().

octomath::Quaternion::Quaternion ( const Vector3 axis,
double  angle 
)

Constructs a Unit Quaternion from a rotation angle and axis.

References u(), octomath::Vector3::x(), x(), octomath::Vector3::y(), y(), octomath::Vector3::z(), and z().


Member Function Documentation

Quaternion octomath::Quaternion::inv ( ) const [inline]

Inversion.

Returns:
A copy of this Quaterion inverted

References Quaternion(), u(), x(), y(), and z().

Referenced by octomath::Pose6D::inv(), octomath::Pose6D::inv_IP(), and rotate().

Quaternion & octomath::Quaternion::inv_IP ( )

Inversion.

Inverts this Quaternion

Returns:
a reference to this Quaternion

References x(), y(), and z().

float octomath::Quaternion::norm ( ) const

References operator()().

Referenced by normalize(), toEuler(), and toRotMatrix().

Quaternion & octomath::Quaternion::normalize ( )

References norm().

Referenced by normalized().

Quaternion octomath::Quaternion::normalized ( ) const
const float& octomath::Quaternion::operator() ( unsigned int  i) const [inline]

References data.

Referenced by norm(), readBinary(), and writeBinary().

float& octomath::Quaternion::operator() ( unsigned int  i) [inline]

References data.

Quaternion octomath::Quaternion::operator* ( const Quaternion other) const

Quaternion multiplication.

Standard Quaternion multiplication which is not commutative.

Returns:
this * other

References Quaternion(), u(), x(), y(), and z().

Quaternion octomath::Quaternion::operator* ( const Vector3 v) const

Quaternion multiplication with extended vector.

Returns:
q * (0, v)

References Quaternion().

void octomath::Quaternion::operator/= ( float  x)
Quaternion & octomath::Quaternion::operator= ( const Quaternion other)

References u(), x(), y(), and z().

Referenced by Quaternion().

bool octomath::Quaternion::operator== ( const Quaternion other) const
std::istream & octomath::Quaternion::read ( std::istream &  s)

Referenced by octomath::Pose6D::read().

std::istream & octomath::Quaternion::readBinary ( std::istream &  s)

References operator()().

Referenced by octomath::Pose6D::readBinary().

Vector3 octomath::Quaternion::rotate ( const Vector3 v) const

Rotate a vector.

Rotates a vector to the body fixed coordinate system according to the attitude represented by this Quaternion.

Parameters:
va vector represented in world coordinates
Returns:
v represented in body-fixed coordinates

References inv(), x(), y(), and z().

Referenced by octomath::Pose6D::inv(), octomath::Pose6D::inv_IP(), octomath::Pose6D::operator*(), octomath::Pose6D::operator*=(), and octomath::Pose6D::transform().

Vector3 octomath::Quaternion::toEuler ( ) const

Conversion to Euler angles.

Converts the attitude represented by this to Euler angles (roll, pitch, yaw).

References norm(), u(), x(), y(), and z().

Referenced by octomath::Pose6D::pitch(), octomath::Pose6D::roll(), and octomath::Pose6D::yaw().

void octomath::Quaternion::toRotMatrix ( std::vector< double > &  rot_matrix_3_3) const

References norm(), u(), x(), y(), and z().

float& octomath::Quaternion::u ( ) [inline]
const float& octomath::Quaternion::u ( ) const [inline]

References data.

std::ostream & octomath::Quaternion::write ( std::ostream &  s) const

Referenced by octomath::Pose6D::write().

std::ostream & octomath::Quaternion::writeBinary ( std::ostream &  s) const

References operator()().

Referenced by octomath::Pose6D::writeBinary().

float& octomath::Quaternion::x ( ) [inline]
const float& octomath::Quaternion::x ( ) const [inline]

References data.

const float& octomath::Quaternion::y ( ) const [inline]

References data.

float& octomath::Quaternion::y ( ) [inline]
const float& octomath::Quaternion::z ( ) const [inline]

References data.

float& octomath::Quaternion::z ( ) [inline]

Friends And Related Function Documentation

Quaternion operator* ( const Vector3 v,
const Quaternion q 
) [friend]

Quaternion multiplication with extended vector.

Returns:
(0, v) * q

Field Documentation

float octomath::Quaternion::data[4] [protected]

Referenced by operator()(), Quaternion(), u(), x(), y(), and z().


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