Public Types | Public Member Functions | Static Public Attributes | Friends | List of all members
quaternion Class Reference

Quaternion class used to perform rotations in 3D space. More...

Collaboration diagram for quaternion:
Collaboration graph
[legend]

Public Types

enum  { rank = 1 }
 
typedef scalar cmptType
 Component type. More...
 

Public Member Functions

 quaternion ()
 Construct null. More...
 
 quaternion (const scalar w, const vector &v)
 Construct given scalar and vector parts. More...
 
 quaternion (const vector &d, const scalar theta)
 Construct a rotation quaternion given the direction d. More...
 
 quaternion (const vector &d, const scalar cosTheta, const bool normalized)
 Construct a rotation quaternion given the direction d. More...
 
 quaternion (const scalar w)
 Construct given scalar part, the vector part = vector::zero. More...
 
 quaternion (const vector &v)
 Construct a pure quaternion given the vector part, scalar part = 0. More...
 
 quaternion (const scalar angleX, const scalar angleY, const scalar angleZ)
 Construct a quaternion given the three Euler angles. More...
 
 quaternion (const tensor &rotationTensor)
 Construct a quaternion from a rotation tensor. More...
 
 quaternion (Istream &)
 Construct from Istream. More...
 
scalar w () const
 Scalar part of the quaternion ( = cos(theta/2) for rotation) More...
 
const vectorv () const
 Vector part of the quaternion ( = axis of rotation) More...
 
tensor R () const
 The rotation tensor corresponding the quaternion. More...
 
vector eulerAngles (const quaternion &q) const
 Return a vector of euler angles (rotations in radians about. More...
 
quaternion normalized () const
 
scalar & w ()
 Scalar part of the quaternion ( = cos(theta/2) for rotation) More...
 
vectorv ()
 Vector part of the quaternion ( = axis of rotation) More...
 
void normalize ()
 
vector transform (const vector &v) const
 Rotate the given vector. More...
 
vector invTransform (const vector &v) const
 Rotate the given vector anti-clockwise. More...
 
quaternion transform (const quaternion &q) const
 Rotate the given quaternion (and normalize) More...
 
quaternion invTransform (const quaternion &q) const
 Rotate the given quaternion anti-clockwise (and normalize) More...
 
void operator= (const quaternion &)
 
void operator+= (const quaternion &)
 
void operator-= (const quaternion &)
 
void operator*= (const quaternion &)
 
void operator/= (const quaternion &)
 
void operator= (const scalar)
 
void operator= (const vector &)
 
void operator*= (const scalar)
 
void operator/= (const scalar)
 

Static Public Attributes

static const char *const typeName = "quaternion"
 
static const quaternion zero
 
static const quaternion I
 

Friends

Istreamoperator>> (Istream &is, quaternion &)
 
Ostreamoperator<< (Ostream &os, const quaternion &C)
 

Detailed Description

Quaternion class used to perform rotations in 3D space.

Source files

Definition at line 60 of file quaternion.H.

Member Typedef Documentation

typedef scalar cmptType

Component type.

Definition at line 78 of file quaternion.H.

Member Enumeration Documentation

anonymous enum
Enumerator
rank 

Definition at line 82 of file quaternion.H.

Constructor & Destructor Documentation

quaternion ( )
inline

Construct null.

Definition at line 28 of file quaternionI.H.

Referenced by Foam::conjugate(), Foam::exp(), Foam::inv(), quaternion::normalize(), Foam::operator*(), Foam::operator+(), Foam::operator-(), Foam::operator/(), and quaternion::quaternion().

Here is the caller graph for this function:

quaternion ( const scalar  w,
const vector v 
)
inline

Construct given scalar and vector parts.

Definition at line 31 of file quaternionI.H.

quaternion ( const vector d,
const scalar  theta 
)
inline

Construct a rotation quaternion given the direction d.

and angle theta

Definition at line 37 of file quaternionI.H.

References quaternion::quaternion().

Here is the call graph for this function:

quaternion ( const vector d,
const scalar  cosTheta,
const bool  normalized 
)
inline

Construct a rotation quaternion given the direction d.

and cosine angle cosTheta and a if d is normalized

Definition at line 44 of file quaternionI.H.

References Foam::mag(), and Foam::sqrt().

Here is the call graph for this function:

quaternion ( const scalar  w)
inlineexplicit

Construct given scalar part, the vector part = vector::zero.

Definition at line 63 of file quaternionI.H.

quaternion ( const vector v)
inlineexplicit

Construct a pure quaternion given the vector part, scalar part = 0.

Definition at line 69 of file quaternionI.H.

References quaternion::quaternion().

Here is the call graph for this function:

quaternion ( const scalar  angleX,
const scalar  angleY,
const scalar  angleZ 
)
inline

Construct a quaternion given the three Euler angles.

Definition at line 76 of file quaternionI.H.

References quaternion::operator*=(), quaternion::operator=(), and quaternion::quaternion().

Here is the call graph for this function:

quaternion ( const tensor rotationTensor)
inlineexplicit

Construct a quaternion from a rotation tensor.

Definition at line 88 of file quaternionI.H.

References s(), Foam::sqrt(), Tensor< Cmpt >::xx(), Tensor< Cmpt >::xy(), Tensor< Cmpt >::xz(), Tensor< Cmpt >::yx(), Tensor< Cmpt >::yy(), Tensor< Cmpt >::yz(), Tensor< Cmpt >::zx(), Tensor< Cmpt >::zy(), and Tensor< Cmpt >::zz().

Here is the call graph for this function:

quaternion ( Istream is)

Construct from Istream.

Definition at line 38 of file quaternion.C.

Member Function Documentation

Foam::scalar w ( ) const
inline
const Foam::vector & v ( ) const
inline
Foam::tensor R ( ) const
inline

The rotation tensor corresponding the quaternion.

Definition at line 235 of file quaternionI.H.

References Foam::sqr(), quaternion::v(), quaternion::w(), x, Vector< Cmpt >::x(), y, Vector< Cmpt >::y(), and Vector< Cmpt >::z().

Referenced by Foam::transform(), and triad::triad().

Here is the call graph for this function:

Here is the caller graph for this function:

Foam::vector eulerAngles ( const quaternion q) const
inline

Return a vector of euler angles (rotations in radians about.

the x, y and z axes.

Definition at line 258 of file quaternionI.H.

References Foam::asin(), Foam::atan2(), Foam::sqr(), quaternion::v(), quaternion::w(), Vector< Cmpt >::x(), Vector< Cmpt >::y(), Vector< Cmpt >::z(), and Vector< Cmpt >::zero.

Here is the call graph for this function:

Foam::quaternion normalized ( ) const
inline

Definition at line 190 of file quaternionI.H.

References Foam::mag().

Here is the call graph for this function:

Foam::scalar & w ( )
inline

Scalar part of the quaternion ( = cos(theta/2) for rotation)

Definition at line 178 of file quaternionI.H.

Foam::vector & v ( )
inline

Vector part of the quaternion ( = axis of rotation)

Definition at line 184 of file quaternionI.H.

void normalize ( )
inline

Definition at line 196 of file quaternionI.H.

References Foam::mag(), quaternion::operator/=(), quaternion::quaternion(), quaternion::v(), and quaternion::w().

Here is the call graph for this function:

Foam::vector transform ( const vector v) const
inline

Rotate the given vector.

Definition at line 208 of file quaternionI.H.

References Foam::conjugate().

Referenced by Foam::operator*(), septernion::operator*=(), and septernion::transform().

Here is the call graph for this function:

Here is the caller graph for this function:

Foam::vector invTransform ( const vector v) const
inline

Rotate the given vector anti-clockwise.

Definition at line 214 of file quaternionI.H.

References Foam::conjugate(), and quaternion::v().

Referenced by Foam::inv(), septernion::invTransform(), and quaternion::transform().

Here is the call graph for this function:

Here is the caller graph for this function:

Foam::quaternion transform ( const quaternion q) const
inline

Rotate the given quaternion (and normalize)

Definition at line 220 of file quaternionI.H.

References quaternion::invTransform(), and Foam::normalize().

Here is the call graph for this function:

Foam::quaternion invTransform ( const quaternion q) const
inline

Rotate the given quaternion anti-clockwise (and normalize)

Definition at line 227 of file quaternionI.H.

References Foam::conjugate(), and Foam::normalize().

Here is the call graph for this function:

void operator= ( const quaternion q)
inline

Definition at line 289 of file quaternionI.H.

Referenced by quaternion::quaternion().

Here is the caller graph for this function:

void operator+= ( const quaternion q)
inline

Definition at line 295 of file quaternionI.H.

void operator-= ( const quaternion q)
inline

Definition at line 301 of file quaternionI.H.

void operator*= ( const quaternion q)
inline

Definition at line 307 of file quaternionI.H.

References quaternion::v(), and quaternion::w().

Referenced by quaternion::operator/=(), and quaternion::quaternion().

Here is the call graph for this function:

Here is the caller graph for this function:

void operator/= ( const quaternion q)
inline

Definition at line 314 of file quaternionI.H.

References Foam::inv(), and quaternion::operator*=().

Referenced by quaternion::normalize().

Here is the call graph for this function:

Here is the caller graph for this function:

void operator= ( const scalar  s)
inline

Definition at line 320 of file quaternionI.H.

References s().

Here is the call graph for this function:

void operator= ( const vector v)
inline

Definition at line 326 of file quaternionI.H.

References quaternion::v().

Here is the call graph for this function:

void operator*= ( const scalar  s)
inline

Definition at line 332 of file quaternionI.H.

References s().

Here is the call graph for this function:

void operator/= ( const scalar  s)
inline

Definition at line 338 of file quaternionI.H.

References s().

Here is the call graph for this function:

Friends And Related Function Documentation

Istream& operator>> ( Istream is,
quaternion  
)
friend
Ostream& operator<< ( Ostream os,
const quaternion C 
)
friend

Member Data Documentation

const char *const typeName = "quaternion"
static

Definition at line 90 of file quaternion.H.

const Foam::quaternion zero
static

Definition at line 92 of file quaternion.H.

const Foam::quaternion I
static

Definition at line 93 of file quaternion.H.


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