Quaternion class used to perform rotations in 3D space. More...
Public Types | |
enum | rotationSequence { ZYX, ZYZ, ZXY, ZXZ, YXZ, YXY, YZX, YZY, XYZ, XYX, XZY, XZX } |
Euler-angle rotation sequence. More... | |
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 normalised) | |
Construct a rotation quaternion given the direction d. More... | |
quaternion (const scalar w) | |
Construct a real from the given scalar part, the vector part = zero. More... | |
quaternion (const vector &v) | |
Construct a pure imaginary quaternion given the vector part,. More... | |
quaternion (const rotationSequence rs, const vector &angles) | |
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 vector & | v () const |
Vector part of the quaternion ( = axis of rotation) More... | |
tensor | R () const |
The rotation tensor corresponding the quaternion. More... | |
vector | eulerAngles (const rotationSequence rs) const |
Return a vector of euler angles corresponding to the. More... | |
quaternion | normalised () const |
scalar & | w () |
Scalar part of the quaternion ( = cos(theta/2) for rotation) More... | |
vector & | v () |
Vector part of the quaternion ( = axis of rotation) More... | |
void | normalise () |
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 normalise) More... | |
quaternion | invTransform (const quaternion &q) const |
Rotate the given quaternion anti-clockwise (and normalise) More... | |
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 Member Functions | |
static quaternion | unit (const vector &v) |
Return the unit quaternion (versor) from the given vector. More... | |
Static Public Attributes | |
static const direction | rank = 1 |
Rank of quaternion is 1. More... | |
static const char *const | typeName = "quaternion" |
static const quaternion | zero |
static const quaternion | I |
Friends | |
Istream & | operator>> (Istream &is, quaternion &) |
Ostream & | operator<< (Ostream &os, const quaternion &C) |
Quaternion class used to perform rotations in 3D space.
Definition at line 60 of file quaternion.H.
typedef scalar cmptType |
Component type.
Definition at line 98 of file quaternion.H.
enum rotationSequence |
Euler-angle rotation sequence.
Enumerator | |
---|---|
ZYX | |
ZYZ | |
ZXY | |
ZXZ | |
YXZ | |
YXY | |
YZX | |
YZY | |
XYZ | |
XYX | |
XZY | |
XZX |
Definition at line 101 of file quaternion.H.
|
inline |
Construct null.
Definition at line 28 of file quaternionI.H.
Referenced by Foam::conjugate(), Foam::exp(), Foam::inv(), quaternion::normalise(), Foam::operator*(), Foam::operator+(), Foam::operator-(), Foam::operator/(), quaternion::quaternion(), and quaternion::unit().
|
inline |
Construct given scalar and vector parts.
Definition at line 32 of file quaternionI.H.
|
inline |
Construct a rotation quaternion given the direction d.
and angle theta
Definition at line 39 of file quaternionI.H.
References quaternion::quaternion().
|
inline |
Construct a rotation quaternion given the direction d.
and cosine angle cosTheta and a if d is normalised
Definition at line 47 of file quaternionI.H.
References Foam::mag(), and Foam::sqrt().
|
inlineexplicit |
Construct a real from the given scalar part, the vector part = zero.
Definition at line 67 of file quaternionI.H.
|
inlineexplicit |
Construct a pure imaginary quaternion given the vector part,.
the scalar part = 0
Definition at line 74 of file quaternionI.H.
|
inline |
Construct a quaternion given the three Euler angles.
Definition at line 88 of file quaternionI.H.
References Foam::abort(), Foam::FatalError, FatalErrorInFunction, quaternion::operator*=(), quaternion::operator=(), quaternion::quaternion(), Vector< Cmpt >::x(), quaternion::XYX, quaternion::XYZ, quaternion::XZX, quaternion::XZY, Vector< Cmpt >::y(), quaternion::YXY, quaternion::YXZ, quaternion::YZX, quaternion::YZY, Vector< Cmpt >::z(), quaternion::ZXY, quaternion::ZXZ, quaternion::ZYX, and quaternion::ZYZ.
|
inlineexplicit |
Construct a quaternion from a rotation tensor.
Definition at line 176 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().
quaternion | ( | Istream & | is | ) |
Construct from Istream.
Definition at line 38 of file quaternion.C.
|
inlinestatic |
Return the unit quaternion (versor) from the given vector.
(w = sqrt(1 - |sqr(v)|))
Definition at line 81 of file quaternionI.H.
References Foam::magSqr(), quaternion::quaternion(), and Foam::sqrt().
Referenced by joint::unitQuaternion().
|
inline |
Scalar part of the quaternion ( = cos(theta/2) for rotation)
Definition at line 254 of file quaternionI.H.
Referenced by Foam::conjugate(), quaternion::eulerAngles(), Foam::exp(), Foam::inv(), Foam::magSqr(), Foam::name(), quaternion::normalise(), Foam::operator*(), quaternion::operator*=(), Foam::operator+(), Foam::operator-(), Foam::operator/(), Foam::operator<<(), Foam::operator==(), Foam::operator>>(), Foam::pow(), and quaternion::R().
|
inline |
Vector part of the quaternion ( = axis of rotation)
Definition at line 260 of file quaternionI.H.
Referenced by Foam::conjugate(), quaternion::eulerAngles(), Foam::exp(), Foam::inv(), quaternion::invTransform(), Foam::magSqr(), Foam::name(), quaternion::normalise(), Foam::operator*(), quaternion::operator*=(), Foam::operator+(), Foam::operator-(), Foam::operator/(), Foam::operator<<(), quaternion::operator=(), Foam::operator==(), Foam::operator>>(), Foam::pow(), quaternion::R(), and joint::unitQuaternion().
|
inline |
The rotation tensor corresponding the quaternion.
Definition at line 323 of file quaternionI.H.
References Foam::acos(), Foam::asin(), Foam::atan2(), Foam::constant::physicoChemical::c2, quaternion::eulerAngles(), Foam::sqr(), quaternion::v(), quaternion::w(), w2, x, Vector< Cmpt >::x(), y, Vector< Cmpt >::y(), and Vector< Cmpt >::z().
Referenced by cyclicTransform::cyclicTransform(), NamedEnum< compressibleField, 8 >::names(), Foam::transform(), Foam::transformPoints(), and triad::triad().
|
inline |
Return a vector of euler angles corresponding to the.
specified rotation sequence
Definition at line 373 of file quaternionI.H.
References Foam::abort(), Foam::FatalError, FatalErrorInFunction, Foam::sqr(), quaternion::v(), quaternion::w(), w2, x, quaternion::XYX, quaternion::XYZ, quaternion::XZX, quaternion::XZY, y, quaternion::YXY, quaternion::YXZ, quaternion::YZX, quaternion::YZY, Foam::Zero, quaternion::ZXY, quaternion::ZXZ, quaternion::ZYX, and quaternion::ZYZ.
Referenced by quaternion::R().
|
inline |
Definition at line 278 of file quaternionI.H.
References Foam::mag().
|
inline |
Scalar part of the quaternion ( = cos(theta/2) for rotation)
Definition at line 266 of file quaternionI.H.
|
inline |
Vector part of the quaternion ( = axis of rotation)
Definition at line 272 of file quaternionI.H.
|
inline |
Definition at line 284 of file quaternionI.H.
References Foam::mag(), quaternion::operator/=(), quaternion::quaternion(), quaternion::v(), and quaternion::w().
Referenced by Foam::average().
|
inline |
Rotate the given vector.
Definition at line 296 of file quaternionI.H.
References Foam::conjugate().
Referenced by searchableExtrudedCircle::findParametricNearest(), Foam::inv(), Foam::operator*(), Foam::operator/(), septernion::operator/=(), and septernion::transformPoint().
|
inline |
Rotate the given vector anti-clockwise.
Definition at line 302 of file quaternionI.H.
References Foam::conjugate(), and quaternion::v().
Referenced by septernion::invTransformPoint(), Foam::operator*(), septernion::operator*=(), and quaternion::transform().
|
inline |
Rotate the given quaternion (and normalise)
Definition at line 308 of file quaternionI.H.
References quaternion::invTransform(), and Foam::normalise().
|
inline |
Rotate the given quaternion anti-clockwise (and normalise)
Definition at line 315 of file quaternionI.H.
References Foam::conjugate(), and Foam::normalise().
|
inline |
Definition at line 526 of file quaternionI.H.
|
inline |
Definition at line 532 of file quaternionI.H.
|
inline |
Definition at line 538 of file quaternionI.H.
References quaternion::v(), quaternion::w(), and w0.
Referenced by quaternion::operator/=(), and quaternion::quaternion().
|
inline |
Definition at line 545 of file quaternionI.H.
References Foam::inv(), and quaternion::operator*=().
Referenced by quaternion::normalise().
|
inline |
Definition at line 551 of file quaternionI.H.
References s().
Referenced by quaternion::quaternion().
|
inline |
Definition at line 557 of file quaternionI.H.
References quaternion::v().
|
inline |
Definition at line 563 of file quaternionI.H.
References s().
|
inline |
Definition at line 569 of file quaternionI.H.
References s().
|
friend |
|
friend |
|
static |
Rank of quaternion is 1.
Definition at line 110 of file quaternion.H.
|
static |
Definition at line 115 of file quaternion.H.
|
static |
Definition at line 117 of file quaternion.H.
|
static |
Definition at line 118 of file quaternion.H.
Referenced by septernion::operator=().