Quaternion class used to perform rotations in 3D space. More...
#include <quaternion.H>

Public Types | |
| enum | eulerOrder : unsigned char { XZX , XYX , YXY , YZY , ZYZ , ZXZ , XZY , XYZ , YXZ , YZX , ZYX , ZXY , ROLL_PITCH_YAW = XYZ , YAW_PITCH_ROLL = ZYX } |
| Euler-angle rotation order. More... | |
| typedef scalar | cmptType |
| Component type. | |
| typedef scalar | magType |
| Magnitude type. | |
Public Member Functions | |
| quaternion ()=default | |
| Default construct. | |
| quaternion (const quaternion &)=default | |
| Copy construct. | |
| quaternion & | operator= (const quaternion &)=default |
| Copy assignment. | |
| quaternion (const Foam::zero) | |
| Construct initialized to zero. | |
| quaternion (const scalar w, const vector &v) | |
| Construct given scalar and vector parts. | |
| quaternion (const vector &d, const scalar theta) | |
| Construct rotation quaternion given direction d and angle theta. | |
| quaternion (const vector &d, const scalar cosTheta, const bool isNormalised) | |
| Construct a rotation quaternion given direction d and cosine angle cosTheta and flag if d is normalised. | |
| quaternion (const scalar w) | |
| Construct a real quaternion from the given scalar part, the vector part = zero. | |
| quaternion (const vector &v) | |
| Construct a pure imaginary quaternion given the vector part, the scalar part = 0. | |
| quaternion (const eulerOrder order, const vector &angles) | |
| Construct from three Euler rotation angles. | |
| quaternion (const tensor &rotationTensor) | |
| Construct from a rotation tensor. | |
| quaternion (Istream &is) | |
| Construct from Istream. | |
| scalar | w () const noexcept |
| Scalar part of the quaternion ( = cos(theta/2) for rotation). | |
| const vector & | v () const noexcept |
| Vector part of the quaternion ( = axis of rotation). | |
| tensor | R () const |
| The rotation tensor corresponding to the quaternion. | |
| vector | eulerAngles (const eulerOrder order) const |
| Return the Euler rotation angles corresponding to the specified rotation order. | |
| scalar & | w () noexcept |
| Scalar part of the quaternion ( = cos(theta/2) for rotation). | |
| vector & | v () noexcept |
| Vector part of the quaternion ( = axis of rotation). | |
| quaternion & | normalise (const scalar tol=ROOTVSMALL) |
| Inplace normalise the quaternion by its magnitude. | |
| vector | transform (const vector &v) const |
| Rotate the given vector. | |
| vector | invTransform (const vector &v) const |
| Rotate the given vector anti-clockwise. | |
| quaternion | transform (const quaternion &q) const |
| Rotate the given quaternion (and normalise). | |
| quaternion | invTransform (const quaternion &q) const |
| Rotate the given quaternion anti-clockwise (and normalise). | |
| 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. | |
| void | operator= (const vector &v) |
| Change vector portion only. | |
| void | operator= (const Foam::zero) |
| Assign scalar and vector to zero. | |
| void | operator*= (const scalar s) |
| void | operator/= (const scalar s) |
| void | normalize () |
| Inplace normalise the quaternion by its magnitude. | |
| quaternion | normalized () const |
| Return the quaternion normalised by its magnitude. | |
Static Public Member Functions | |
| static quaternion | unit (const vector &v) |
| Return the unit quaternion (versor) from the given vector (w = sqrt(1 - |sqr(v)|)). | |
Static Public Attributes | |
| static const Enum< eulerOrder > | eulerOrderNames |
| The names for Euler-angle and Tait-Bryan angles, including "rollPitchYaw" and "yawPitchRoll" aliases. | |
| static constexpr direction | rank = 1 |
| Rank of quaternion is 1. | |
| 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 53 of file quaternion.H.
| typedef scalar cmptType |
Component type.
Definition at line 105 of file quaternion.H.
| typedef scalar magType |
Magnitude type.
Definition at line 110 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 | |
| ROLL_PITCH_YAW | |
| YAW_PITCH_ROLL | |
Definition at line 115 of file quaternion.H.
|
default |
Default construct.
Referenced by invTransform(), normalized(), operator*=(), operator+=(), operator-=(), operator/=(), operator=(), quaternion(), quaternion(), transform(), and unit().

|
default |
|
inline |
|
inline |
Construct given scalar and vector parts.
Definition at line 31 of file quaternionI.H.

|
inline |
Construct rotation quaternion given direction d and angle theta.
Definition at line 38 of file quaternionI.H.
References Foam::cos(), Foam::normalised(), and Foam::sin().

|
inline |
Construct a rotation quaternion given direction d and cosine angle cosTheta and flag if d is normalised.
Definition at line 45 of file quaternionI.H.
References Foam::normalised(), and Foam::sqrt().

|
inlineexplicit |
Construct a real quaternion from the given scalar part, the vector part = zero.
Definition at line 66 of file quaternionI.H.
References w(), and Foam::Zero.

|
inlineexplicit |
Construct a pure imaginary quaternion given the vector part, the scalar part = 0.
Definition at line 73 of file quaternionI.H.
References v().

|
inline |
Construct from three Euler rotation angles.
Definition at line 86 of file quaternionI.H.
References Foam::abort(), Foam::FatalError, FatalErrorInFunction, operator*=(), operator=(), quaternion(), Vector< Cmpt >::x(), XYX, XYZ, XZX, XZY, Vector< Cmpt >::y(), YXY, YXZ, YZX, YZY, Vector< Cmpt >::z(), ZXY, ZXZ, ZYX, and ZYZ.

|
inlineexplicit |
Construct from a rotation tensor.
Definition at line 199 of file quaternionI.H.
References Foam::rotationTensor(), s(), and Foam::sqrt().

|
explicit |
Construct from Istream.
Definition at line 58 of file quaternion.C.
|
default |
Copy assignment.
References eulerAngles(), Foam::FOAM_DEPRECATED_FOR(), invTransform(), Foam::noexcept, normalise(), quaternion(), R(), Foam::rotationTensor(), s(), transform(), v(), w(), and zero.
Referenced by quaternion().


|
inlinestatic |
Return the unit quaternion (versor) from the given vector (w = sqrt(1 - |sqr(v)|)).
Definition at line 80 of file quaternionI.H.
References Foam::magSqr(), quaternion(), Foam::sqrt(), and v().
Referenced by joint::unitQuaternion().


|
inlinenoexcept |
Scalar part of the quaternion ( = cos(theta/2) for rotation).
Definition at line 278 of file quaternionI.H.
References Foam::noexcept.
Referenced by Foam::conjugate(), eulerAngles(), Foam::exp(), Foam::inv(), Foam::magSqr(), Foam::name(), Foam::operator&(), Foam::operator*(), Foam::operator*(), operator*=(), Foam::operator-(), Foam::operator/(), Foam::operator<<(), operator=(), Foam::operator==(), Foam::operator>>(), Foam::pow(), Foam::pow(), quaternion(), quaternion(), and R().

|
inlinenoexcept |
Vector part of the quaternion ( = axis of rotation).
Definition at line 284 of file quaternionI.H.
References Foam::noexcept.
Referenced by Foam::conjugate(), eulerAngles(), Foam::exp(), Foam::inv(), Foam::magSqr(), Foam::name(), Foam::operator&(), Foam::operator*(), Foam::operator*(), operator*=(), Foam::operator-(), Foam::operator/(), Foam::operator<<(), operator=(), operator=(), Foam::operator==(), Foam::operator>>(), Foam::pow(), Foam::pow(), quaternion(), quaternion(), R(), unit(), and joint::unitQuaternion().

|
inline |
The rotation tensor corresponding to the quaternion.
Definition at line 352 of file quaternionI.H.
References Foam::sqr(), v(), w(), w2, x, and y.
Referenced by operator=(), axisAngle::rotation(), Foam::transform(), and triad::triad().


|
inline |
Return the Euler rotation angles corresponding to the specified rotation order.
Definition at line 401 of file quaternionI.H.
References Foam::abort(), Foam::FatalError, FatalErrorInFunction, Foam::sqr(), v(), w(), w2, x, XYX, XYZ, XZX, XZY, y, YXY, YXZ, YZX, YZY, Foam::Zero, ZXY, ZXZ, ZYX, and ZYZ.
Referenced by operator=(), and sixDoFRigidBodyState::write().


|
inlinenoexcept |
Scalar part of the quaternion ( = cos(theta/2) for rotation).
Definition at line 290 of file quaternionI.H.
References Foam::noexcept.
|
inlinenoexcept |
Vector part of the quaternion ( = axis of rotation).
Definition at line 296 of file quaternionI.H.
References Foam::noexcept.
|
inline |
Inplace normalise the quaternion by its magnitude.
For small magnitudes (less than ROOTVSMALL) set to zero.
Definition at line 302 of file quaternionI.H.
References Foam::mag(), and s().
Referenced by Foam::average(), rigidBodySolver::correctQuaternionJoints(), normalize(), normalized(), and operator=().


|
inline |
Rotate the given vector.
Definition at line 325 of file quaternionI.H.
References Foam::conjugate().
Referenced by searchableExtrudedCircle::findParametricNearest(), polyline::operator()(), and operator=().


|
inline |
Rotate the given vector anti-clockwise.
Definition at line 331 of file quaternionI.H.
References Foam::conjugate().
Referenced by operator=().


|
inline |
Rotate the given quaternion (and normalise).
Definition at line 337 of file quaternionI.H.
References Foam::normalised(), and quaternion().

|
inline |
Rotate the given quaternion anti-clockwise (and normalise).
Definition at line 343 of file quaternionI.H.
References Foam::conjugate(), Foam::normalised(), and quaternion().

|
inline |
Definition at line 582 of file quaternionI.H.
References quaternion().

|
inline |
Definition at line 588 of file quaternionI.H.
References quaternion().

|
inline |
Definition at line 594 of file quaternionI.H.
References quaternion(), v(), w(), and w0.
Referenced by operator/=(), and quaternion().


|
inline |
Definition at line 601 of file quaternionI.H.
References Foam::inv(), operator*=(), and quaternion().

|
inline |
Change scalar portion only.
Definition at line 607 of file quaternionI.H.
References s().

|
inline |
Change vector portion only.
Definition at line 613 of file quaternionI.H.
References v().

|
inline |
Assign scalar and vector to zero.
Definition at line 619 of file quaternionI.H.
References Foam::Zero.
|
inline |
Definition at line 626 of file quaternionI.H.
References s().

|
inline |
Definition at line 632 of file quaternionI.H.
References s().

|
inline |
Inplace normalise the quaternion by its magnitude.
Definition at line 332 of file quaternion.H.
References normalise(), and normalize().
Referenced by normalize().


|
inline |
Return the quaternion normalised by its magnitude.
Definition at line 338 of file quaternion.H.
References normalise(), normalized(), and quaternion().
Referenced by normalized().


|
static |
The names for Euler-angle and Tait-Bryan angles, including "rollPitchYaw" and "yawPitchRoll" aliases.
Definition at line 132 of file quaternion.H.
Referenced by Foam::lumpedPointTools::lumpedPointStates(), lumpedPointState::writeDict(), and euler::writeEntry().
|
staticconstexpr |
Rank of quaternion is 1.
Definition at line 140 of file quaternion.H.
|
staticconstexpr |
Definition at line 145 of file quaternion.H.
|
static |
Definition at line 147 of file quaternion.H.
Referenced by operator=().
|
static |
Definition at line 148 of file quaternion.H.
Referenced by septernion::operator=().