GCOP  1.0
Public Member Functions | Static Public Member Functions | Public Attributes | Protected Attributes | Friends
gcop::Quat Class Reference

#include <quat.h>

List of all members.

Public Member Functions

 Quat ()
 Quat (const Quat &q)
 Quat (const double q[4])
 Quat (double w, double x, double y, double z)
virtual ~Quat ()
double * Rotate2 (double c[3], const double a[3]) const
double * Rotate2 (double c[3]) const
double * Rotate (double c[3], const double v[3]) const
double * Rotate (double v[3]) const
void Transform (const double e[3])
void Transform (const double u[3], double v)
void Invert ()
void Invert (Quat &q) const
void Identity ()
void Normalize ()
Quatoperator*= (const Quat &q)
void FromExp (const double e[3])
void ToExp (double e[3]) const
void FromAxis (const double u[3], const double v)
void ToAxis (double u[3], double &v) const
void FromSE3 (const double m[16])
void ToSE3 (double m[16]) const
void FromRpy (const double rpy[3])
void ToRpy (double rpy[3]) const
double * Q (double q[4]) const
bool IsIdentity () const
void SetTol (double tol)

Static Public Member Functions

static double * Rotate (double c[3], const double v[3], const double u[3], double w)

Public Attributes

double qw
double qx
double qy
double qz
 quaternion components

Protected Attributes

double tol
 operations tolerance (default is 1e-10)

Friends

const Quat operator* (const Quat &q0, const Quat &q1)
std::ostream & operator<< (std::ostream &os, const Quat &q)
std::istream & operator>> (std::istream &is, Quat &q)

Detailed Description

The class defines a quaternion and its basic set of operations. This is a minimalistic implementation that contains only 5 doubles: 4 numbers describing the quaternion coordinates: $ q \in S^3 \subset \mathbb{R}^4 $ and a number tol that defines the numerical tolerance for quaternion operations. The implemented functionality is suitable for efficient quaternion algebra; for various actions on vectors in $ \mathbb{R}^3$; for transforming b/n quaternion, matrix, and exponential representations

Author: Marin Kobilarov -- (C) 2003


Constructor & Destructor Documentation

Initialize identity quaternion

References EPS.

Quat::Quat ( const Quat q)

Copy contructor

Parameters:
qquaternion
gcop::Quat::Quat ( const double  q[4])

Initialize using a double array

Parameters:
qquaternion vector
Quat::Quat ( double  w,
double  x,
double  y,
double  z 
)

Initialize using seperate quaternion components $ q=[w,x,y,z] $

Parameters:
ww
xx
yy
zz
Quat::~Quat ( ) [virtual]

Member Function Documentation

void Quat::FromAxis ( const double  u[3],
const double  v 
)

Create from angle-axis representation

Parameters:
uaxis (unit vector)
vangle

References Normalize(), qw, qx, qy, and qz.

Referenced by Rotate(), and Transform().

void Quat::FromExp ( const double  e[3])

Create from exponential coordinates

Parameters:
eexponential coordinates

References qw, qx, qy, and qz.

Referenced by Transform().

void Quat::FromRpy ( const double  rpy[3])

From roll-pitch-yaw angles

Parameters:
rpyroll-pitch-yaw angles

References Normalize(), qw, qx, qy, and qz.

void Quat::FromSE3 ( const double  m[16])

Extract this quaternion from an SE(3) matrix

Parameters:
m4x4 matrix

References mat, Normalize(), perm, qw, qx, qy, and qz.

void Quat::Identity ( )

Set this quaternion to the identity

References qw, qx, qy, and qz.

void Quat::Invert ( )

Invert the quaternion

References qx, qy, and qz.

Referenced by Rotate().

void Quat::Invert ( Quat q) const

Create an inverse of this quaternion and store it in q

Parameters:
qinverse of this quaternion

References qw, qx, qy, and qz.

bool Quat::IsIdentity ( ) const

Check if it's identity up to defined tolerance tol

References qw, qx, qy, qz, and tol.

Referenced by operator*=(), Rotate(), ToAxis(), ToExp(), and ToRpy().

void Quat::Normalize ( )

Normalize $ q = \frac{q}{\|q\|} $

References qw, qx, qy, and qz.

Referenced by FromAxis(), FromRpy(), and FromSE3().

Quat & Quat::operator*= ( const Quat q)

Multiply with another quaternion

Parameters:
qother quaterion
Returns:
resulting quaternion

References IsIdentity(), qw, qx, qy, and qz.

double * Quat::Q ( double  q[4]) const

Get a 4-dim array with the quaternion components

Parameters:
qthe array to be filled
Returns:
pointer to q

References qw, qx, qy, and qz.

double * Quat::Rotate ( double  c[3],
const double  v[3],
const double  u[3],
double  w 
) [static]

Rotate a vector v using around axis u by angle w and store resulting vector in c

Parameters:
cresulting vector
vinitial vector
uaxis of rotation
wangle of rotation
Returns:
a pointer to c

References FromAxis(), and Rotate().

Referenced by Rotate().

double * Quat::Rotate ( double  c[3],
const double  v[3] 
) const

Rotate a vector v and store in c

Parameters:
cresulting vector
vinitial vector
Returns:
a pointer to c

References Invert(), IsIdentity(), ToExp(), and tol.

double * Quat::Rotate ( double  v[3]) const

Rotate a vector v and store the resulting vector back in v

Parameters:
vvector to rotate
Returns:
pointer to v

References Rotate().

double * Quat::Rotate2 ( double  c[3],
const double  a[3] 
) const

References qw, qx, qy, and qz.

Referenced by Rotate2().

double * Quat::Rotate2 ( double  c[3]) const

References Rotate2().

void Quat::SetTol ( double  tol)

Set the operations tolerance (default is 1e-10)

Parameters:
toltolerance

References tol.

void Quat::ToAxis ( double  u[3],
double &  v 
) const

To angle-axis (or exponential/canonical) representation

Parameters:
uresulting axis (unit vector)
vresulting angle (optional)

References IsIdentity(), qw, qx, qy, and qz.

void Quat::ToExp ( double  e[3]) const

To exponential coordinates

Parameters:
eexponential coordinates

References IsIdentity(), qw, qx, qy, qz, and tol.

Referenced by Rotate().

void Quat::ToRpy ( double  rpy[3]) const

To roll-pitch-yaw angles

Parameters:
rpyroll-pitch-yaw angles

References IsIdentity(), qw, qx, qy, and qz.

void Quat::ToSE3 ( double  m[16]) const

Create a 4x4 SE(3) matrix from this quaternion

Parameters:
mmatrix

References qw, qx, qy, and qz.

void Quat::Transform ( const double  e[3])

Transform this quaternion by exponential coordinates e. Note: norm(e)<pi so this is suitable for small rotations e

Parameters:
eexponential coordinates

References FromExp().

void Quat::Transform ( const double  u[3],
double  v 
)

Transform this quaternion by axis u and angle v

Parameters:
uaxis of rotation
vangle of rotation

References FromAxis().


Friends And Related Function Documentation

const Quat operator* ( const Quat q0,
const Quat q1 
) [friend]

Multiply two quaternions and return the result $ q=q_0*q_1 $

Parameters:
q0first quat
q1second quat
Returns:
their product
std::ostream& operator<< ( std::ostream &  os,
const Quat q 
) [friend]

Print a quaternion

Parameters:
osoutput stream
qquaternion
Returns:
the output stream
std::istream& operator>> ( std::istream &  is,
Quat q 
) [friend]

Load a quaternion

Parameters:
isinput stream
qquaternion
Returns:
the input stream

Member Data Documentation

double gcop::Quat::tol [protected]

operations tolerance (default is 1e-10)

Referenced by IsIdentity(), Rotate(), SetTol(), and ToExp().


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