octomap  1.9.7
octomath::Quaternion Class Reference

This class represents a Quaternion. More...

Public Member Functions

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

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

◆ Quaternion() [1/6]

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().

◆ Quaternion() [2/6]

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

Copy constructor.

References data.

◆ Quaternion() [3/6]

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().

◆ Quaternion() [4/6]

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().

◆ Quaternion() [5/6]

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().

◆ Quaternion() [6/6]

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

◆ inv()

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().

◆ inv_IP()

Quaternion & octomath::Quaternion::inv_IP ( )

Inversion.

Inverts this Quaternion

Returns
a reference to this Quaternion

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

◆ norm()

float octomath::Quaternion::norm ( ) const

References operator()().

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

◆ normalize()

Quaternion & octomath::Quaternion::normalize ( )

References norm().

Referenced by normalized().

◆ normalized()

Quaternion octomath::Quaternion::normalized ( ) const

◆ operator()() [1/2]

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

References data.

◆ operator()() [2/2]

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

References data.

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

◆ operator*() [1/2]

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().

◆ operator*() [2/2]

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

Quaternion multiplication with extended vector.

Returns
q * (0, v)

References Quaternion().

◆ operator/=()

void octomath::Quaternion::operator/= ( float  x)

References x().

◆ operator=()

Quaternion & octomath::Quaternion::operator= ( const Quaternion other)

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

Referenced by Quaternion().

◆ operator==()

bool octomath::Quaternion::operator== ( const Quaternion other) const

◆ read()

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

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

◆ readBinary()

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

References operator()().

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

◆ rotate()

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().

◆ toEuler()

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(), octomap::ScanNode::writePoseASCII(), and octomath::Pose6D::yaw().

◆ toRotMatrix()

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

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

◆ u() [1/2]

float& octomath::Quaternion::u ( )
inline

◆ u() [2/2]

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

References data.

◆ write()

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

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

◆ writeBinary()

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

References operator()().

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

◆ x() [1/2]

float& octomath::Quaternion::x ( )
inline

◆ x() [2/2]

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

References data.

◆ y() [1/2]

float& octomath::Quaternion::y ( )
inline

◆ y() [2/2]

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

References data.

◆ z() [1/2]

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

◆ z() [2/2]

const float& octomath::Quaternion::z ( ) const
inline

References data.

Friends And Related Function Documentation

◆ operator*

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

Quaternion multiplication with extended vector.

Returns
(0, v) * q

Field Documentation

◆ data

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: