Main MRPT website > C++ reference
MRPT logo

mrpt::math::CQuaternion< T > Class Template Reference

A quaternion, which can represent a 3D rotation as pair $ (r,\mathbf{u}) $, with a real part "r" and a 3D vector $ \mathbf{u} = (x,y,z) $, or alternatively, q = r + ix + jy + kz. More...

#include <mrpt/math/CQuaternion.h>

Inheritance diagram for mrpt::math::CQuaternion< T >:
Inheritance graph
[legend]
Collaboration diagram for mrpt::math::CQuaternion< T >:
Collaboration graph
[legend]

List of all members.

Public Member Functions



 CQuaternion (bool, bool)
 Can be used with UNINITIALIZED_QUATERNION as argument, does not initialize the 4 elements of the quaternion (use this constructor when speed is critical).
 CQuaternion ()
 Default constructor: construct a (1, (0,0,0) ) quaternion representing no rotation.
 CQuaternion (const T r, const T x, const T y, const T z)
 Construct a quaternion from its parameters 'r', 'x', 'y', 'z', with q = r + ix + jy + kz.
r () const
 Return r coordinate of the quaternion.
x () const
 Return x coordinate of the quaternion.
y () const
 Return y coordinate of the quaternion.
z () const
 Return z coordinate of the quaternion.
void r (const T r)
 Set r coordinate of the quaternion.
void x (const T x)
 Set x coordinate of the quaternion.
void y (const T y)
 Set y coordinate of the quaternion.
void z (const T z)
 Set z coordinate of the quaternion.
template<class ARRAYLIKE >
void fromRodriguesVector (const ARRAYLIKE &in)
 Set this quaternion to the rotation described by a 3D Rodrigues rotation vector.
void crossProduct (const CQuaternion &q1, const CQuaternion &q2)
 Calculate the "cross" product (or "composed rotation") of two quaternion: this = q1 x q2 After the operation, "this" will represent the composed rotations of q1 and q2 (q2 applied "after" q1).
void rotatePoint (const double lx, const double ly, const double lz, double &gx, double &gy, double &gz) const
 Rotate a 3D point (lx,ly,lz) -> (gx,gy,gz) as described by this quaternion.
void inverseRotatePoint (const double lx, const double ly, const double lz, double &gx, double &gy, double &gz) const
 Rotate a 3D point (lx,ly,lz) -> (gx,gy,gz) as described by the inverse (conjugate) of this quaternion.
double normSqr () const
 Return the squared norm of the quaternion.
void normalize ()
 Normalize this quaternion, so its norm becomes the unitity.
template<class MATRIXLIKE >
void normalizationJacobian (MATRIXLIKE &J) const
 Calculate the 4x4 Jacobian of the normalization operation of this quaternion.
template<class MATRIXLIKE >
void rotationJacobian (MATRIXLIKE &J) const
 Compute the Jacobian of the rotation composition operation $ p = f(\cdot) = q_{this} \times r $, that is the 4x4 matrix $ \frac{\partial f}{\partial q_{this} } $.
template<class MATRIXLIKE >
void rotationMatrix (MATRIXLIKE &M) const
 Calculate the 3x3 rotation matrix associated to this quaternion.
template<class MATRIXLIKE >
void rotationMatrixNoResize (MATRIXLIKE &M) const
 Fill out the top-left 3x3 block of the given matrix with the rotation matrix associated to this quaternion (does not resize the matrix, for that, see rotationMatrix).
void conj (CQuaternion &q_out) const
 Return the conjugate quaternion.
CQuaternion conj () const
 Return the conjugate quaternion.
void rpy (T &roll, T &pitch, T &yaw) const
 Return the yaw, pitch & roll angles associated to quaternion.
template<class MATRIXLIKE >
void rpy_and_jacobian (T &roll, T &pitch, T &yaw, MATRIXLIKE *out_dr_dq=NULL, bool resize_out_dr_dq_to3x4=true) const
 Return the yaw, pitch & roll angles associated to quaternion, and (optionally) the 3x4 Jacobian of the transformation.
CQuaternion operator* (const T &factor)

Private Types

typedef CArrayNumeric< T, 4 > BASE

Detailed Description

template<class T>
class mrpt::math::CQuaternion< T >

A quaternion, which can represent a 3D rotation as pair $ (r,\mathbf{u}) $, with a real part "r" and a 3D vector $ \mathbf{u} = (x,y,z) $, or alternatively, q = r + ix + jy + kz.

The elements of the quaternion can be accessed by either:

Users will usually employ the typedef "CQuaternionDouble" instead of this template.

For more information about quaternions, see:

See also:
mrpt::poses::CPose3D

Definition at line 59 of file CQuaternion.h.


Member Typedef Documentation

template<class T>
typedef CArrayNumeric<T,4> mrpt::math::CQuaternion< T >::BASE [private]

Definition at line 61 of file CQuaternion.h.


Constructor & Destructor Documentation

template<class T>
mrpt::math::CQuaternion< T >::CQuaternion ( bool  ,
bool   
) [inline]

Can be used with UNINITIALIZED_QUATERNION as argument, does not initialize the 4 elements of the quaternion (use this constructor when speed is critical).

Definition at line 67 of file CQuaternion.h.

template<class T>
mrpt::math::CQuaternion< T >::CQuaternion (  )  [inline]

Default constructor: construct a (1, (0,0,0) ) quaternion representing no rotation.

Definition at line 70 of file CQuaternion.h.

template<class T>
mrpt::math::CQuaternion< T >::CQuaternion ( const T  r,
const T  x,
const T  y,
const T  z 
) [inline]

Construct a quaternion from its parameters 'r', 'x', 'y', 'z', with q = r + ix + jy + kz.

Definition at line 79 of file CQuaternion.h.


Member Function Documentation

template<class T>
CQuaternion mrpt::math::CQuaternion< T >::conj (  )  const [inline]

Return the conjugate quaternion.

Definition at line 247 of file CQuaternion.h.

Referenced by mrpt::math::CQuaternion< double >::conj().

template<class T>
void mrpt::math::CQuaternion< T >::conj ( CQuaternion< T > &  q_out  )  const [inline]

Return the conjugate quaternion.

Definition at line 238 of file CQuaternion.h.

template<class T>
void mrpt::math::CQuaternion< T >::crossProduct ( const CQuaternion< T > &  q1,
const CQuaternion< T > &  q2 
) [inline]

Calculate the "cross" product (or "composed rotation") of two quaternion: this = q1 x q2 After the operation, "this" will represent the composed rotations of q1 and q2 (q2 applied "after" q1).

Definition at line 133 of file CQuaternion.h.

template<class T>
template<class ARRAYLIKE >
void mrpt::math::CQuaternion< T >::fromRodriguesVector ( const ARRAYLIKE &  in  )  [inline]

Set this quaternion to the rotation described by a 3D Rodrigues rotation vector.

Definition at line 104 of file CQuaternion.h.

template<class T>
void mrpt::math::CQuaternion< T >::inverseRotatePoint ( const double  lx,
const double  ly,
const double  lz,
double &  gx,
double &  gy,
double &  gz 
) const [inline]

Rotate a 3D point (lx,ly,lz) -> (gx,gy,gz) as described by the inverse (conjugate) of this quaternion.

Definition at line 155 of file CQuaternion.h.

template<class T>
template<class MATRIXLIKE >
void mrpt::math::CQuaternion< T >::normalizationJacobian ( MATRIXLIKE &  J  )  const [inline]

Calculate the 4x4 Jacobian of the normalization operation of this quaternion.

The output matrix can be a dynamic or fixed size (4x4) matrix.

Definition at line 180 of file CQuaternion.h.

template<class T>
void mrpt::math::CQuaternion< T >::normalize (  )  [inline]

Normalize this quaternion, so its norm becomes the unitity.

Definition at line 169 of file CQuaternion.h.

Referenced by mrpt::math::CQuaternion< double >::crossProduct().

template<class T>
double mrpt::math::CQuaternion< T >::normSqr (  )  const [inline]
template<class T>
CQuaternion mrpt::math::CQuaternion< T >::operator* ( const T &  factor  )  [inline]

Definition at line 336 of file CQuaternion.h.

template<class T>
void mrpt::math::CQuaternion< T >::r ( const T  r  )  [inline]

Set r coordinate of the quaternion.

Definition at line 96 of file CQuaternion.h.

template<class T>
T mrpt::math::CQuaternion< T >::r (  )  const [inline]
template<class T>
void mrpt::math::CQuaternion< T >::rotatePoint ( const double  lx,
const double  ly,
const double  lz,
double &  gx,
double &  gy,
double &  gz 
) const [inline]

Rotate a 3D point (lx,ly,lz) -> (gx,gy,gz) as described by this quaternion.

Definition at line 144 of file CQuaternion.h.

template<class T>
template<class MATRIXLIKE >
void mrpt::math::CQuaternion< T >::rotationJacobian ( MATRIXLIKE &  J  )  const [inline]

Compute the Jacobian of the rotation composition operation $ p = f(\cdot) = q_{this} \times r $, that is the 4x4 matrix $ \frac{\partial f}{\partial q_{this} } $.

The output matrix can be a dynamic or fixed size (4x4) matrix.

Definition at line 210 of file CQuaternion.h.

template<class T>
template<class MATRIXLIKE >
void mrpt::math::CQuaternion< T >::rotationMatrix ( MATRIXLIKE &  M  )  const [inline]

Calculate the 3x3 rotation matrix associated to this quaternion.

Definition at line 221 of file CQuaternion.h.

template<class T>
template<class MATRIXLIKE >
void mrpt::math::CQuaternion< T >::rotationMatrixNoResize ( MATRIXLIKE &  M  )  const [inline]

Fill out the top-left 3x3 block of the given matrix with the rotation matrix associated to this quaternion (does not resize the matrix, for that, see rotationMatrix).

Definition at line 229 of file CQuaternion.h.

Referenced by mrpt::math::CQuaternion< double >::rotationMatrix().

template<class T>
void mrpt::math::CQuaternion< T >::rpy ( T &  roll,
T &  pitch,
T &  yaw 
) const [inline]

Return the yaw, pitch & roll angles associated to quaternion.

See also:
For the equations, see The MRPT Book, or see http://www.euclideanspace.com/maths/geometry/rotations/conversions/quaternionToEuler/Quaternions.pdf
rpy_and_jacobian

Definition at line 258 of file CQuaternion.h.

template<class T>
template<class MATRIXLIKE >
void mrpt::math::CQuaternion< T >::rpy_and_jacobian ( T &  roll,
T &  pitch,
T &  yaw,
MATRIXLIKE *  out_dr_dq = NULL,
bool  resize_out_dr_dq_to3x4 = true 
) const [inline]

Return the yaw, pitch & roll angles associated to quaternion, and (optionally) the 3x4 Jacobian of the transformation.

Note that both the angles and the Jacobian have one set of normal equations, plus other special formulas for the degenerated cases of |pitch|=90 degrees.

See also:
For the equations, see The MRPT Book, or http://www.euclideanspace.com/maths/geometry/rotations/conversions/quaternionToEuler/Quaternions.pdf
rpy

Definition at line 269 of file CQuaternion.h.

Referenced by mrpt::math::CQuaternion< double >::rpy().

template<class T>
void mrpt::math::CQuaternion< T >::x ( const T  x  )  [inline]

Set x coordinate of the quaternion.

Definition at line 97 of file CQuaternion.h.

template<class T>
T mrpt::math::CQuaternion< T >::x (  )  const [inline]
template<class T>
void mrpt::math::CQuaternion< T >::y ( const T  y  )  [inline]

Set y coordinate of the quaternion.

Definition at line 98 of file CQuaternion.h.

template<class T>
T mrpt::math::CQuaternion< T >::y (  )  const [inline]
template<class T>
void mrpt::math::CQuaternion< T >::z ( const T  z  )  [inline]

Set z coordinate of the quaternion.

Definition at line 99 of file CQuaternion.h.

template<class T>
T mrpt::math::CQuaternion< T >::z (  )  const [inline]
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines



Page generated by Doxygen 1.6.1 for MRPT 0.9.0 SVN: at Mon Jun 7 06:47:58 UTC 2010