Quaternion class used to perform rotations in 3D space. More...
Public Types | |
enum | eulerOrder : unsigned char { XZX, XYX, YXY, YZY, ZYZ, ZXZ, XZY, XYZ, YXZ, YZX, ZYX, ZXY } |
Euler-angle rotation order. More... | |
typedef scalar | cmptType |
Component type. More... | |
typedef scalar | magType |
Magnitude type. More... | |
Public Member Functions | |
quaternion ()=default | |
Default construct. More... | |
quaternion (const quaternion &)=default | |
Copy construct. More... | |
quaternion & | operator= (const quaternion &)=default |
Copy assignment. More... | |
quaternion (const Foam::zero) | |
Construct zero initialized. More... | |
quaternion (const scalar w, const vector &v) | |
Construct given scalar and vector parts. More... | |
quaternion (const vector &d, const scalar theta) | |
Construct rotation quaternion given direction d and angle theta. More... | |
quaternion (const vector &d, const scalar cosTheta, const bool normalized) | |
quaternion (const scalar w) | |
quaternion (const vector &v) | |
quaternion (const eulerOrder order, const vector &angles) | |
Construct from three Euler rotation angles. More... | |
quaternion (const tensor &rotationTensor) | |
Construct from a rotation tensor. More... | |
quaternion (Istream &is) | |
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 to the quaternion. More... | |
vector | eulerAngles (const eulerOrder order) const |
quaternion | normalized () const |
Return the quaternion normalized by its magnitude. More... | |
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 | normalize () |
Normalize the quaternion by its magnitude. More... | |
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 &q) |
void | operator-= (const quaternion &q) |
void | operator*= (const quaternion &q) |
void | operator/= (const quaternion &q) |
void | operator= (const scalar s) |
Change scalar portion only. More... | |
void | operator= (const vector &v) |
Change vector portion only. More... | |
void | operator*= (const scalar s) |
void | operator/= (const scalar s) |
Static Public Member Functions | |
static quaternion | unit (const vector &v) |
Static Public Attributes | |
static const Enum< eulerOrder > | eulerOrderNames |
The names for Euler-angle rotation order. More... | |
static constexpr direction | rank = 1 |
Rank of quaternion is 1. More... | |
static constexpr const char *const | typeName = "quaternion" |
static const quaternion | zero |
static const quaternion | I |
Quaternion class used to perform rotations in 3D space.
Definition at line 56 of file quaternion.H.
typedef scalar cmptType |
Component type.
Definition at line 96 of file quaternion.H.
typedef scalar magType |
Magnitude type.
Definition at line 99 of file quaternion.H.
enum eulerOrder : unsigned char |
Euler-angle rotation order.
Enumerator | |
---|---|
XZX | |
XYX | |
YXY | |
YZY | |
ZYZ | |
ZXZ | |
XZY | |
XYZ | |
YXZ | |
YZX | |
ZYX | |
ZXY |
Definition at line 102 of file quaternion.H.
|
default |
Default construct.
|
default |
Copy construct.
|
inline |
Construct zero initialized.
Definition at line 31 of file quaternionI.H.
|
inline |
Construct given scalar and vector parts.
Definition at line 38 of file quaternionI.H.
|
inline |
Construct rotation quaternion given direction d and angle theta.
Definition at line 45 of file quaternionI.H.
|
inline |
Construct a rotation quaternion given direction d and cosine angle cosTheta and flag if d is normalized
Definition at line 53 of file quaternionI.H.
References Foam::mag(), and Foam::sqrt().
|
inlineexplicit |
Construct a real quaternion from the given scalar part, the vector part = zero
Definition at line 73 of file quaternionI.H.
|
inlineexplicit |
Construct a pure imaginary quaternion given the vector part, the scalar part = 0
Definition at line 80 of file quaternionI.H.
|
inline |
Construct from three Euler rotation angles.
Definition at line 94 of file quaternionI.H.
References Foam::abort(), Foam::FatalError, FatalErrorInFunction, Vector< Cmpt >::x(), Vector< Cmpt >::y(), and Vector< Cmpt >::z().
|
inlineexplicit |
Construct from a rotation tensor.
Definition at line 207 of file quaternionI.H.
References Foam::rotationTensor(), 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().
|
explicit |
Construct from Istream.
Definition at line 61 of file quaternion.C.
|
default |
Copy assignment.
|
inlinestatic |
Return the unit quaternion (versor) from the given vector (w = sqrt(1 - |sqr(v)|))
Definition at line 87 of file quaternionI.H.
References Foam::magSqr(), and Foam::sqrt().
Referenced by joint::unitQuaternion().
|
inline |
Scalar part of the quaternion ( = cos(theta/2) for rotation)
Definition at line 285 of file quaternionI.H.
Referenced by Foam::conjugate(), Foam::exp(), Foam::inv(), Foam::magSqr(), Foam::name(), Foam::operator&(), Foam::operator*(), quaternion::operator*=(), Foam::operator+(), Foam::operator-(), Foam::operator/(), Foam::operator<<(), Foam::operator==(), Foam::operator>>(), and Foam::pow().
|
inline |
Vector part of the quaternion ( = axis of rotation)
Definition at line 291 of file quaternionI.H.
Referenced by Foam::conjugate(), Foam::exp(), Foam::inv(), Foam::magSqr(), Foam::name(), Foam::operator&(), Foam::operator*(), quaternion::operator*=(), Foam::operator+(), Foam::operator-(), Foam::operator/(), Foam::operator<<(), Foam::operator==(), Foam::operator>>(), Foam::pow(), and joint::unitQuaternion().
|
inline |
The rotation tensor corresponding to the quaternion.
Definition at line 354 of file quaternionI.H.
References Foam::sqr(), w2, x, and y.
Referenced by axisAngle::rotation(), Foam::transform(), and triad::triad().
|
inline |
Return the Euler rotation angles corresponding to the specified rotation order
Definition at line 404 of file quaternionI.H.
References Foam::abort(), Foam::FatalError, FatalErrorInFunction, Foam::sqr(), w2, x, y, and Foam::Zero.
|
inline |
Return the quaternion normalized by its magnitude.
Definition at line 309 of file quaternionI.H.
References Foam::mag().
|
inline |
Scalar part of the quaternion ( = cos(theta/2) for rotation)
Definition at line 297 of file quaternionI.H.
|
inline |
Vector part of the quaternion ( = axis of rotation)
Definition at line 303 of file quaternionI.H.
|
inline |
Normalize the quaternion by its magnitude.
Definition at line 315 of file quaternionI.H.
References Foam::mag().
Referenced by Foam::average().
|
inline |
Rotate the given vector.
Definition at line 327 of file quaternionI.H.
References Foam::conjugate().
Referenced by searchableExtrudedCircle::findParametricNearest(), Foam::operator*(), Foam::operator/(), and septernion::operator/=().
|
inline |
Rotate the given vector anti-clockwise.
Definition at line 333 of file quaternionI.H.
References Foam::conjugate().
Referenced by Foam::operator*(), and septernion::operator*=().
|
inline |
Rotate the given quaternion (and normalize)
Definition at line 339 of file quaternionI.H.
References Foam::normalize().
|
inline |
Rotate the given quaternion anti-clockwise (and normalize)
Definition at line 346 of file quaternionI.H.
References Foam::conjugate(), and Foam::normalize().
|
inline |
Definition at line 584 of file quaternionI.H.
|
inline |
Definition at line 590 of file quaternionI.H.
|
inline |
Definition at line 596 of file quaternionI.H.
References quaternion::v(), quaternion::w(), and w0.
|
inline |
Definition at line 603 of file quaternionI.H.
References Foam::inv().
|
inline |
|
inline |
Change vector portion only.
Definition at line 615 of file quaternionI.H.
|
inline |
Definition at line 621 of file quaternionI.H.
References s.
|
inline |
Definition at line 627 of file quaternionI.H.
References s.
|
static |
The names for Euler-angle rotation order.
Definition at line 112 of file quaternion.H.
Referenced by lumpedPointMovement::readDict(), lumpedPointState::writeDict(), and euler::writeEntry().
|
staticconstexpr |
Rank of quaternion is 1.
Definition at line 118 of file quaternion.H.
|
staticconstexpr |
Definition at line 123 of file quaternion.H.
|
static |
Definition at line 125 of file quaternion.H.
|
static |
Definition at line 126 of file quaternion.H.
Referenced by septernion::operator=().