FGQuaternion Class Reference

#include <FGQuaternion.h>

Inherits FGJSBBase.

List of all members.


Detailed Description

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.

See also:
Cooke, Zyda, Pratt, and McGhee, "NPSNET: Flight Simulation Dynamic Modeling Using Quaternions", Presence, Vol. 1, No. 4, pp. 404-420 Naval Postgraduate School, January 1994

D. M. Henderson, "Euler Angles, Quaternions, and Transformation Matrices", JSC 12960, July 1977

Richard E. McFarland, "A Standard Kinematic Model for Flight Simulation at NASA-Ames", NASA CR-2497, January 1975

Barnes W. McCormick, "Aerodynamics, Aeronautics, and Flight Mechanics", Wiley & Sons, 1979 ISBN 0-471-03032-5

Bernard Etkin, "Dynamics of Flight, Stability and Control", Wiley & Sons, 1982 ISBN 0-471-08936-2

Author:
Mathias Froehlich, extended FGColumnVector4 originally by Tony Peden and Jon Berndt

Definition at line 91 of file FGQuaternion.h.


Public Member Functions

FGQuaternion Conjugate (void) const
 Conjugate of the quaternion.
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.
 FGQuaternion (int idx, double angle)
 Initializer by one euler angle.
 FGQuaternion (double phi, double tht, double psi)
 Initializer by euler angles.
 FGQuaternion (const FGQuaternion &q)
 Copy constructor.
 FGQuaternion ()
 Default initializer.
double GetCosEuler (int i) const
 Retrieves cosine of the given euler angle.
double GetEuler (int i) const
 Retrieves the Euler angles.
const FGColumnVector3GetEuler (void) const
 Retrieves the Euler angles.
double GetEulerDeg (int i) const
 Retrieves the Euler angles.
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 FGMatrix33GetT (void) const
 Transformation matrix.
const FGMatrix33GetTInv (void) const
 Backward transformation matrix.
FGQuaternion Inverse (void) const
 Inverse of the quaternion.
double Magnitude (void) const
 Length of the vector.
void Normalize (void)
 Normialze.
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 FGQuaternionoperator*= (const FGQuaternion &q)
 Arithmetic operator "*=".
const FGQuaternionoperator*= (double scalar)
 Arithmetic operator "*=".
FGQuaternion operator+ (const FGQuaternion &q) const
 Arithmetic operator "+".
const FGQuaternionoperator+= (const FGQuaternion &q)
FGQuaternion operator- (const FGQuaternion &q) const
 Arithmetic operator "-".
const FGQuaternionoperator-= (const FGQuaternion &q)
 Arithmetic operator "-=".
const FGQuaternionoperator/= (double scalar)
 Arithmetic operator "/=".
const FGQuaternionoperator= (const FGQuaternion &q)
 Assignment operator "=".
bool operator== (const FGQuaternion &q) const
 Comparison operator "==".
double SqrMagnitude (void) const
 Square of the length of the vector.
 ~FGQuaternion ()
 Destructor.

Static Public Member Functions

static FGQuaternion zero (void)
 Zero quaternion vector.

Friends

FGQuaternion operator* (double, const FGQuaternion &)
 Scalar multiplication.

Constructor & Destructor Documentation

FGQuaternion (  )  [inline]

Default initializer, initializes the class with the identity rotation.

Definition at line 96 of file FGQuaternion.h.

FGQuaternion ( const FGQuaternion q  ) 

Copy constructor, initializes the quaternion.

Parameters:
q a constant reference to another FGQuaternion instance

Definition at line 65 of file FGQuaternion.cpp.

FGQuaternion ( double  phi,
double  tht,
double  psi 
)

Initialize the quaternion with the euler angles.

Parameters:
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 83 of file FGQuaternion.cpp.

FGQuaternion ( int  idx,
double  angle 
) [inline]

Initialize the quaternion with the single euler angle where its index is given in the first argument.

Parameters:
idx Index of the euler angle to initialize
angle The euler angle in radians

Definition at line 118 of file FGQuaternion.h.


Member Function Documentation

FGQuaternion Conjugate ( void   )  const [inline]

Compute and return the conjugate of the quaternion. This one is equal to the inverse iff the quaternion is normalized.

Definition at line 407 of file FGQuaternion.h.

double& Entry ( unsigned int  idx  )  [inline]

Parameters:
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 264 of file FGQuaternion.h.

double Entry ( unsigned int  idx  )  const [inline]

Parameters:
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 249 of file FGQuaternion.h.

double GetCosEuler ( int  i  )  const [inline]

Returns:
the sine of the Euler angle theta (pitch attitude) corresponding to this quaternion rotation.

Definition at line 209 of file FGQuaternion.h.

double GetEuler ( int  i  )  const [inline]

Parameters:
i the euler angle index. units radians.
Returns:
a reference to the i-th euler angles corresponding to this quaternion rotation.

Definition at line 183 of file FGQuaternion.h.

const FGColumnVector3& GetEuler ( void   )  const [inline]

Returns:
a reference to the triad of euler angles corresponding to this quaternion rotation. units radians

Definition at line 172 of file FGQuaternion.h.

double GetEulerDeg ( int  i  )  const [inline]

Parameters:
i the euler angle index.
Returns:
a reference to the i-th euler angles corresponding to this quaternion rotation. units degrees

Definition at line 193 of file FGQuaternion.h.

FGQuaternion GetQDot ( const FGColumnVector3 PQR  )  const

Returns the derivative of the quaternion corresponding to the angular velocities PQR.

Computes the quaternion derivative which results from the given angular velocities

Parameters:
PQR a constant reference to the body rate vector
Returns:
the quaternion derivative
See also:
Stevens and Lewis, "Aircraft Control and Simulation", Second Edition, Equation 1.3-36.
See Stevens and Lewis, "Aircraft Control and Simulation", Second Edition, Equation 1.3-36.

Definition at line 115 of file FGQuaternion.cpp.

double GetSinEuler ( int  i  )  const [inline]

Returns:
the sine of the Euler angle theta (pitch attitude) corresponding to this quaternion rotation.

Definition at line 201 of file FGQuaternion.h.

const FGMatrix33& GetT ( void   )  const [inline]

Returns:
a reference to the transformation/rotation matrix corresponding to this quaternion rotation.

Definition at line 161 of file FGQuaternion.h.

const FGMatrix33& GetTInv ( void   )  const [inline]

Returns:
a reference to the inverse transformation/rotation matrix corresponding to this quaternion rotation.

Definition at line 166 of file FGQuaternion.h.

FGQuaternion Inverse ( void   )  const [inline]

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 393 of file FGQuaternion.h.

double Magnitude ( void   )  const [inline]

Compute and return the euclidean norm of this vector.

Definition at line 417 of file FGQuaternion.h.

void Normalize ( void   ) 

Normalize the vector to have the Magnitude() == 1.0. If the vector is equal to zero it is left untouched.

Definition at line 131 of file FGQuaternion.cpp.

bool operator!= ( const FGQuaternion q  )  const [inline]

Parameters:
q a quaternion reference
Returns:
true if both quaternions do not represent the same rotation.

Definition at line 300 of file FGQuaternion.h.

double& operator() ( unsigned int  idx  )  [inline]

Parameters:
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 234 of file FGQuaternion.h.

double operator() ( unsigned int  idx  )  const [inline]

Parameters:
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 223 of file FGQuaternion.h.

FGQuaternion operator* ( const FGQuaternion q  )  const [inline]

Multiplication of two quaternions is like performing successive rotations.

Parameters:
q a quaternion to be multiplied.
Returns:
a quaternion representing Q, where Q = Q * q.

Definition at line 363 of file FGQuaternion.h.

const FGQuaternion& operator*= ( const FGQuaternion q  )  [inline]

Multiplication of two quaternions is like performing successive rotations.

Parameters:
q a quaternion to be multiplied.
Returns:
a quaternion reference representing Q, where Q = Q * q.

Definition at line 374 of file FGQuaternion.h.

const FGQuaternion& operator*= ( double  scalar  )  [inline]

Parameters:
scalar a multiplicative value.
Returns:
a quaternion reference representing Q, where Q = Q * scalar.

Definition at line 327 of file FGQuaternion.h.

FGQuaternion operator+ ( const FGQuaternion q  )  const [inline]

Parameters:
q a quaternion to be summed.
Returns:
a quaternion representing Q, where Q = Q + q.

Definition at line 346 of file FGQuaternion.h.

FGQuaternion operator- ( const FGQuaternion q  )  const [inline]

Parameters:
q a quaternion to be subtracted.
Returns:
a quaternion representing Q, where Q = Q - q.

Definition at line 354 of file FGQuaternion.h.

const FGQuaternion& operator-= ( const FGQuaternion q  )  [inline]

Parameters:
q a quaternion reference.
Returns:
a quaternion reference representing Q, where Q = Q - q.

Definition at line 314 of file FGQuaternion.h.

const FGQuaternion& operator/= ( double  scalar  )  [inline]

Parameters:
scalar a divisor value.
Returns:
a quaternion reference representing Q, where Q = Q / scalar.

Definition at line 339 of file FGQuaternion.h.

const FGQuaternion& operator= ( const FGQuaternion q  )  [inline]

Assign the value of q to the current object. Cached values are conserved.

Parameters:
q reference to an FGQuaternion instance
Returns:
reference to a quaternion object

Definition at line 271 of file FGQuaternion.h.

bool operator== ( const FGQuaternion q  )  const [inline]

Parameters:
q a quaternion reference
Returns:
true if both quaternions represent the same rotation.

Definition at line 292 of file FGQuaternion.h.

double SqrMagnitude ( void   )  const [inline]

Compute and return the square of the euclidean norm of this vector.

Definition at line 423 of file FGQuaternion.h.

static FGQuaternion zero ( void   )  [inline, static]

Does not represent any orientation. Useful for initialization of increments

Definition at line 437 of file FGQuaternion.h.


Friends And Related Function Documentation

FGQuaternion operator* ( double  scalar,
const FGQuaternion q 
) [friend]

Parameters:
scalar scalar value to multiply with.
q Vector to multiply.
Multiply the Vector with a scalar value.

Definition at line 491 of file FGQuaternion.h.


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

Generated on Tue May 26 00:55:12 2009 for JSBSim Flight Dynamics Model by  doxygen 1.5.5