![]() |
JSBSim Flight Dynamics Model 1.2.2 (22 Mar 2025)
An Open Source Flight Dynamics and Control Software Library in C++
|
Models the Quaternion representation of rotations.
FGQuaternion is a representation of an arbitrary rotation through a quaternion. It has vector properties. This class also contains access functions to the euler angle representation of rotations and access to transformation matrices for 3D vectors. Transformations and euler angles are therefore computed once they are requested for the first time. Then they are cached for later usage as long as the class is not accessed trough a nonconst member function.
Note: The order of rotations used in this class corresponds to a 3-2-1 sequence, or Y-P-R, or Z-Y-X, if you prefer.
Definition at line 86 of file FGQuaternion.h.
#include <FGQuaternion.h>
Public Member Functions | |
FGQuaternion () | |
Default initializer. | |
FGQuaternion (const FGMatrix33 &m) | |
Initializer by matrix. | |
FGQuaternion (const FGQuaternion &q) | |
Copy constructor. | |
FGQuaternion (double angle, const FGColumnVector3 &axis) | |
Initializer by a rotation axis and an angle. | |
FGQuaternion (double phi, double tht, double psi) | |
Initializer by euler angles. | |
FGQuaternion (FGColumnVector3 vOrient) | |
Initializer by euler angle vector. | |
FGQuaternion (int idx, double angle) | |
Initializer by one euler angle. | |
~FGQuaternion () | |
Destructor. | |
FGQuaternion | Conjugate (void) const |
Conjugate of the quaternion. | |
std::string | Dump (const std::string &delimiter) const |
double & | Entry (unsigned int idx) |
Write access the entries of the vector. | |
double | Entry (unsigned int idx) const |
Read access the entries of the vector. | |
double | GetCosEuler (int i) const |
Retrieves cosine of the given euler angle. | |
double | GetEuler (int i) const |
Retrieves the Euler angles. | |
const FGColumnVector3 & | GetEuler (void) const |
Retrieves the Euler angles. | |
double | GetEulerDeg (int i) const |
Retrieves the Euler angles. | |
FGColumnVector3 const | GetEulerDeg (void) const |
Retrieves the Euler angle vector. | |
FGQuaternion | GetQDot (const FGColumnVector3 &PQR) const |
Quaternion derivative for given angular rates. | |
double | GetSinEuler (int i) const |
Retrieves sine of the given euler angle. | |
const FGMatrix33 & | GetT (void) const |
Transformation matrix. | |
const FGMatrix33 & | GetTInv (void) const |
Backward transformation matrix. | |
FGQuaternion | Inverse (void) const |
Inverse of the quaternion. | |
double | Magnitude (void) const |
Length of the vector. | |
void | Normalize (void) |
Normalize. | |
operator FGMatrix33 () const | |
Conversion from Quat to Matrix. | |
bool | operator!= (const FGQuaternion &q) const |
Comparison operator "!=". | |
double & | operator() (unsigned int idx) |
Write access the entries of the vector. | |
double | operator() (unsigned int idx) const |
Read access the entries of the vector. | |
FGQuaternion | operator* (const FGQuaternion &q) const |
Arithmetic operator "*". | |
const FGQuaternion & | operator*= (const FGQuaternion &q) |
Arithmetic operator "*=". | |
const FGQuaternion & | operator*= (double scalar) |
Arithmetic operator "*=". | |
FGQuaternion | operator+ (const FGQuaternion &q) const |
Arithmetic operator "+". | |
const FGQuaternion & | operator+= (const FGQuaternion &q) |
FGQuaternion | operator- (const FGQuaternion &q) const |
Arithmetic operator "-". | |
const FGQuaternion & | operator-= (const FGQuaternion &q) |
Arithmetic operator "-=". | |
const FGQuaternion & | operator/= (double scalar) |
Arithmetic operator "/=". | |
const FGQuaternion & | operator= (const FGQuaternion &q) |
Assignment operator "=". | |
bool | operator== (const FGQuaternion &q) const |
Comparison operator "==". | |
double | SqrMagnitude (void) const |
Square of the length of the vector. | |
![]() | |
FGJSBBase () | |
Constructor for FGJSBBase. | |
virtual | ~FGJSBBase () |
Destructor for FGJSBBase. | |
void | disableHighLighting (void) |
Disables highlighting in the console output. | |
Static Public Member Functions | |
static FGQuaternion | zero (void) |
Zero quaternion vector. | |
![]() | |
static const std::string & | GetVersion (void) |
Returns the version number of JSBSim. | |
static constexpr double | KelvinToFahrenheit (double kelvin) |
Converts from degrees Kelvin to degrees Fahrenheit. | |
static constexpr double | CelsiusToRankine (double celsius) |
Converts from degrees Celsius to degrees Rankine. | |
static constexpr double | RankineToCelsius (double rankine) |
Converts from degrees Rankine to degrees Celsius. | |
static constexpr double | KelvinToRankine (double kelvin) |
Converts from degrees Kelvin to degrees Rankine. | |
static constexpr double | RankineToKelvin (double rankine) |
Converts from degrees Rankine to degrees Kelvin. | |
static constexpr double | FahrenheitToCelsius (double fahrenheit) |
Converts from degrees Fahrenheit to degrees Celsius. | |
static constexpr double | CelsiusToFahrenheit (double celsius) |
Converts from degrees Celsius to degrees Fahrenheit. | |
static constexpr double | CelsiusToKelvin (double celsius) |
Converts from degrees Celsius to degrees Kelvin. | |
static constexpr double | KelvinToCelsius (double kelvin) |
Converts from degrees Kelvin to degrees Celsius. | |
static constexpr double | FeetToMeters (double measure) |
Converts from feet to meters. | |
static bool | EqualToRoundoff (double a, double b) |
Finite precision comparison. | |
static bool | EqualToRoundoff (float a, float b) |
Finite precision comparison. | |
static bool | EqualToRoundoff (float a, double b) |
Finite precision comparison. | |
static bool | EqualToRoundoff (double a, float b) |
Finite precision comparison. | |
static constexpr double | Constrain (double min, double value, double max) |
Constrain a value between a minimum and a maximum value. | |
static constexpr double | sign (double num) |
Friends | |
FGQuaternion | operator* (double, const FGQuaternion &) |
Scalar multiplication. | |
FGQuaternion | QExp (const FGColumnVector3 &omega) |
Quaternion exponential. | |
Additional Inherited Members | |
![]() | |
enum | { eL = 1 , eM , eN } |
Moments L, M, N. More... | |
enum | { eP = 1 , eQ , eR } |
Rates P, Q, R. More... | |
enum | { eU = 1 , eV , eW } |
Velocities U, V, W. More... | |
enum | { eX = 1 , eY , eZ } |
Positions X, Y, Z. More... | |
enum | { ePhi = 1 , eTht , ePsi } |
Euler angles Phi, Theta, Psi. More... | |
enum | { eDrag = 1 , eSide , eLift } |
Stability axis forces, Drag, Side force, Lift. More... | |
enum | { eRoll = 1 , ePitch , eYaw } |
Local frame orientation Roll, Pitch, Yaw. More... | |
enum | { eNorth = 1 , eEast , eDown } |
Local frame position North, East, Down. More... | |
enum | { eLat = 1 , eLong , eRad } |
Locations Radius, Latitude, Longitude. More... | |
enum | { inNone = 0 , inDegrees , inRadians , inMeters , inFeet } |
Conversion specifiers. More... | |
![]() | |
static char | highint [5] = {27, '[', '1', 'm', '\0' } |
highlights text | |
static char | halfint [5] = {27, '[', '2', 'm', '\0' } |
low intensity text | |
static char | normint [6] = {27, '[', '2', '2', 'm', '\0' } |
normal intensity text | |
static char | reset [5] = {27, '[', '0', 'm', '\0' } |
resets text properties | |
static char | underon [5] = {27, '[', '4', 'm', '\0' } |
underlines text | |
static char | underoff [6] = {27, '[', '2', '4', 'm', '\0' } |
underline off | |
static char | fgblue [6] = {27, '[', '3', '4', 'm', '\0' } |
blue text | |
static char | fgcyan [6] = {27, '[', '3', '6', 'm', '\0' } |
cyan text | |
static char | fgred [6] = {27, '[', '3', '1', 'm', '\0' } |
red text | |
static char | fggreen [6] = {27, '[', '3', '2', 'm', '\0' } |
green text | |
static char | fgdef [6] = {27, '[', '3', '9', 'm', '\0' } |
default text | |
static short | debug_lvl = 1 |
![]() | |
static std::string | CreateIndexedPropertyName (const std::string &Property, int index) |
![]() | |
static constexpr double | radtodeg = 180. / M_PI |
static constexpr double | degtorad = M_PI / 180. |
static constexpr double | hptoftlbssec = 550.0 |
static constexpr double | psftoinhg = 0.014138 |
static constexpr double | psftopa = 47.88 |
static constexpr double | fttom = 0.3048 |
static constexpr double | ktstofps = 1852./(3600*fttom) |
static constexpr double | fpstokts = 1.0 / ktstofps |
static constexpr double | inchtoft = 1.0/12.0 |
static constexpr double | m3toft3 = 1.0/(fttom*fttom*fttom) |
static constexpr double | in3tom3 = inchtoft*inchtoft*inchtoft/m3toft3 |
static constexpr double | inhgtopa = 3386.38 |
static constexpr double | slugtolb = 32.174049 |
Note that definition of lbtoslug by the inverse of slugtolb and not to a different constant you can also get from some tables will make lbtoslug*slugtolb == 1 up to the magnitude of roundoff. | |
static constexpr double | lbtoslug = 1.0/slugtolb |
static constexpr double | kgtolb = 2.20462 |
static constexpr double | kgtoslug = 0.06852168 |
static const std::string | needed_cfg_version = "2.0" |
static const std::string | JSBSim_version = JSBSIM_VERSION " " __DATE__ " " __TIME__ |
|
inline |
Default initializer.
Default initializer, initializes the class with the identity rotation.
Definition at line 90 of file FGQuaternion.h.
FGQuaternion | ( | const FGQuaternion & | q | ) |
Copy constructor.
Copy constructor, initializes the quaternion.
q | a constant reference to another FGQuaternion instance |
Definition at line 64 of file FGQuaternion.cpp.
FGQuaternion | ( | double | phi, |
double | tht, | ||
double | psi | ||
) |
Initializer by euler angles.
Initialize the quaternion with the euler angles.
phi | The euler X axis (roll) angle in radians |
tht | The euler Y axis (attitude) angle in radians |
psi | The euler Z axis (heading) angle in radians |
Definition at line 82 of file FGQuaternion.cpp.
FGQuaternion | ( | FGColumnVector3 | vOrient | ) |
Initializer by euler angle vector.
Initialize the quaternion with the euler angle vector.
vOrient | The euler axis angle vector in radians (phi, tht, psi) |
Definition at line 89 of file FGQuaternion.cpp.
|
inline |
Initializer by one euler angle.
Initialize the quaternion with the single euler angle where its index is given in the first argument.
idx | Index of the euler angle to initialize |
angle | The euler angle in radians |
Definition at line 117 of file FGQuaternion.h.
|
inline |
Initializer by a rotation axis and an angle.
Initialize the quaternion to represent the rotation around a given angle and an arbitrary axis.
angle | The angle in radians |
axis | The rotation axis |
Definition at line 152 of file FGQuaternion.h.
FGQuaternion | ( | const FGMatrix33 & | m | ) |
Initializer by matrix.
Initialize the quaternion with the matrix representing a transform from one frame to another using the standard aerospace sequence, Yaw-Pitch-Roll (3-2-1).
m | the rotation matrix |
Definition at line 139 of file FGQuaternion.cpp.
|
inline |
|
inline |
Conjugate of the quaternion.
Compute and return the conjugate of the quaternion. This one is equal to the inverse iff the quaternion is normalized.
Definition at line 450 of file FGQuaternion.h.
std::string Dump | ( | const std::string & | delimiter | ) | const |
Definition at line 239 of file FGQuaternion.cpp.
|
inline |
Write access the entries of the vector.
idx | the component index. |
Return a reference to the vector entry at the given index. Indices are counted starting with 1.
This function is just a shortcut for the double& operator()(unsigned int idx)
function. It is used internally to access the elements in a more convenient way.
Note that the index given in the argument is unchecked.
Definition at line 300 of file FGQuaternion.h.
|
inline |
Read access the entries of the vector.
idx | the component index. |
Return the value of the matrix entry at the given index. Indices are counted starting with 1.
This function is just a shortcut for the double operator()(unsigned int idx) const
function. It is used internally to access the elements in a more convenient way.
Note that the index given in the argument is unchecked.
Definition at line 285 of file FGQuaternion.h.
|
inline |
Retrieves cosine of the given euler angle.
Definition at line 245 of file FGQuaternion.h.
|
inline |
Retrieves the Euler angles.
i | the Euler angle index. units radians. |
Definition at line 210 of file FGQuaternion.h.
|
inline |
Retrieves the Euler angles.
Definition at line 199 of file FGQuaternion.h.
|
inline |
Retrieves the Euler angles.
i | the Euler angle index. |
Definition at line 220 of file FGQuaternion.h.
|
inline |
Retrieves the Euler angle vector.
Definition at line 229 of file FGQuaternion.h.
FGQuaternion GetQDot | ( | const FGColumnVector3 & | PQR | ) | const |
Quaternion derivative for given angular rates.
Returns the derivative of the quaternion corresponding to the angular velocities PQR.
Computes the quaternion derivative which results from the given angular velocities
PQR | a constant reference to a rotation rate vector |
See Stevens and Lewis, "Aircraft Control and Simulation", Second Edition, Equation 1.3-36. Also see Jack Kuipers, "Quaternions and Rotation Sequences", Equation 11.12.
Definition at line 158 of file FGQuaternion.cpp.
|
inline |
Retrieves sine of the given euler angle.
Definition at line 237 of file FGQuaternion.h.
|
inline |
Transformation matrix.
Definition at line 188 of file FGQuaternion.h.
|
inline |
Backward transformation matrix.
Definition at line 193 of file FGQuaternion.h.
|
inline |
Inverse of the quaternion.
Compute and return the inverse of the quaternion so that the orientation represented with *this multiplied with the returned value is equal to the identity orientation.
Definition at line 436 of file FGQuaternion.h.
|
inline |
Length of the vector.
Compute and return the euclidean norm of this vector.
Definition at line 460 of file FGQuaternion.h.
void Normalize | ( | void | ) |
Normalize.
Normalize the vector to have the Magnitude() == 1.0. If the vector is equal to zero it is left untouched.
Definition at line 170 of file FGQuaternion.cpp.
|
inline |
Conversion from Quat to Matrix.
Definition at line 330 of file FGQuaternion.h.
|
inline |
Comparison operator "!=".
q | a quaternion reference |
Definition at line 343 of file FGQuaternion.h.
|
inline |
Write access the entries of the vector.
idx | the component index. |
Return a reference to the vector entry at the given index. Indices are counted starting with 1.
Note that the index given in the argument is unchecked.
Definition at line 270 of file FGQuaternion.h.
|
inline |
Read access the entries of the vector.
idx | the component index. |
Return the value of the matrix entry at the given index. Indices are counted starting with 1.
Note that the index given in the argument is unchecked.
Definition at line 259 of file FGQuaternion.h.
|
inline |
Arithmetic operator "*".
Multiplication of two quaternions is like performing successive rotations.
q | a quaternion to be multiplied. |
Definition at line 406 of file FGQuaternion.h.
|
inline |
Arithmetic operator "*=".
Multiplication of two quaternions is like performing successive rotations.
q | a quaternion to be multiplied. |
Definition at line 417 of file FGQuaternion.h.
|
inline |
Arithmetic operator "*=".
scalar | a multiplicative value. |
Definition at line 370 of file FGQuaternion.h.
|
inline |
Arithmetic operator "+".
q | a quaternion to be summed. |
Definition at line 389 of file FGQuaternion.h.
|
inline |
Definition at line 344 of file FGQuaternion.h.
|
inline |
Arithmetic operator "-".
q | a quaternion to be subtracted. |
Definition at line 397 of file FGQuaternion.h.
|
inline |
Arithmetic operator "-=".
q | a quaternion reference. |
Definition at line 357 of file FGQuaternion.h.
|
inline |
Arithmetic operator "/=".
scalar | a divisor value. |
Definition at line 382 of file FGQuaternion.h.
|
inline |
Assignment operator "=".
Assign the value of q to the current object. Cached values are conserved.
q | reference to an FGQuaternion instance |
Definition at line 310 of file FGQuaternion.h.
|
inline |
Comparison operator "==".
q | a quaternion reference |
Definition at line 335 of file FGQuaternion.h.
|
inline |
Square of the length of the vector.
Compute and return the square of the euclidean norm of this vector.
Definition at line 466 of file FGQuaternion.h.
|
inlinestatic |
Zero quaternion vector.
Does not represent any orientation. Useful for initialization of increments
Definition at line 480 of file FGQuaternion.h.
|
friend |
Scalar multiplication.
scalar | scalar value to multiply with. |
q | Vector to multiply. |
Multiply the Vector with a scalar value.
Definition at line 539 of file FGQuaternion.h.
|
friend |
Quaternion exponential.
omega | rotation velocity Calculate the unit quaternion which is the result of the exponentiation of the vector 'omega'. |
Definition at line 548 of file FGQuaternion.h.