Quaternion class definition. More...
#include <quaternion.h>
Public Member Functions | |
Quaternion | conjugate () const |
Conjugate. | |
Quaternion | dot (const ColumnVector &w, const short sign) const |
Quaternion time derivative. | |
Real | dot_prod (const Quaternion &q) const |
Quaternion dot product. | |
ReturnMatrix | E (const short sign) const |
Matrix E. | |
Quaternion | exp () const |
Exponential of a quaternion. | |
Quaternion | i () const |
Quaternion inverse.
where and are the quaternion conjugate and the quaternion norm respectively. | |
Quaternion | Log () const |
Logarithm of a unit quaternion. | |
Real | norm () const |
Return the quaternion norm. | |
Quaternion | operator* (const Quaternion &q) const |
Overload * operator. | |
Quaternion | operator+ (const Quaternion &q) const |
Overload + operator. | |
Quaternion | operator- (const Quaternion &q) const |
Overload - operator. | |
Quaternion | operator/ (const Quaternion &q) const |
Overload / operator. | |
Quaternion | power (const Real t) const |
Quaternion () | |
Constructor. | |
Quaternion (const Real angle_in_rad, const ColumnVector &axis) | |
Constructor. | |
Quaternion (const Real s, const Real v1, const Real v2, const Real v3) | |
Constructor. | |
Quaternion (const Matrix &R) | |
Constructor. | |
ReturnMatrix | R () const |
Rotation matrix from a unit quaternion. | |
Real | s () const |
Return scalar part. | |
void | set_s (const Real s) |
Set scalar part. | |
void | set_v (const ColumnVector &v) |
Set vector part. | |
ReturnMatrix | T () const |
Transformation matrix from a quaternion. | |
Quaternion & | unit () |
Normalize a quaternion. | |
ReturnMatrix | v () const |
Return vector part. | |
Private Attributes | |
Real | s_ |
Quaternion scalar part. | |
ColumnVector | v_ |
Quaternion vector part. |
Quaternion class definition.
Definition at line 92 of file quaternion.h.
Constructor.
Definition at line 77 of file quaternion.cpp.
Quaternion::Quaternion | ( | const Real | angle_in_rad, |
const ColumnVector & | axis | ||
) |
Constructor.
Definition at line 85 of file quaternion.cpp.
Quaternion::Quaternion | ( | const Real | s, |
const Real | v1, | ||
const Real | v2, | ||
const Real | v3 | ||
) |
Constructor.
Definition at line 109 of file quaternion.cpp.
Quaternion::Quaternion | ( | const Matrix & | R | ) |
Constructor.
Cite_: Dam. The unit quaternion obtained from a matrix (see Quaternion::R())
First we find :
Now the other values are:
The sign of cannot be determined. Depending on the choice of the sign for s the sign of change as well. Thus the quaternions and represent the same rotation, but the interpolation curve changed with the choice of the sign. A positive sign has been chosen.
Definition at line 120 of file quaternion.cpp.
Quaternion Quaternion::conjugate | ( | ) | const |
Quaternion Quaternion::dot | ( | const ColumnVector & | w, |
const short | sign | ||
) | const |
Quaternion time derivative.
The quaternion time derivative, quaternion propagation equation, is
where is the angular velocity vector expressed in the base frame. If the vector is expressed in the object frame, , the time derivative becomes
Definition at line 388 of file quaternion.cpp.
Real Quaternion::dot_prod | ( | const Quaternion & | q | ) | const |
Quaternion dot product.
The dot product of quaternion is defined by
Definition at line 445 of file quaternion.cpp.
ReturnMatrix Quaternion::E | ( | const short | sign | ) | const |
Quaternion Quaternion::exp | ( | ) | const |
Exponential of a quaternion.
Let a quaternion of the form , q is not necessarily a unit quaternion. Then the exponential function is defined by .
Definition at line 336 of file quaternion.cpp.
Quaternion Quaternion::i | ( | ) | const |
Quaternion inverse.
where and are the quaternion conjugate and the quaternion norm respectively.
Definition at line 323 of file quaternion.cpp.
Quaternion Quaternion::Log | ( | ) | const |
Logarithm of a unit quaternion.
The logarithm function of a unit quaternion is defined as . The result is not necessary a unit quaternion.
Definition at line 365 of file quaternion.cpp.
Real Quaternion::norm | ( | ) | const |
Return the quaternion norm.
The norm of quaternion is defined by
Definition at line 298 of file quaternion.cpp.
Quaternion Quaternion::operator* | ( | const Quaternion & | rhs | ) | const |
Overload * operator.
The multiplication of two quaternions is
where and denote the scalar and vector product in respectively.
If and are unit quaternions, then q will also be a unit quaternion.
Definition at line 243 of file quaternion.cpp.
Quaternion Quaternion::operator+ | ( | const Quaternion & | rhs | ) | const |
Overload + operator.
The quaternion addition is
The result is not necessarily a unit quaternion even if and are unit quaternions.
Definition at line 203 of file quaternion.cpp.
Quaternion Quaternion::operator- | ( | const Quaternion & | rhs | ) | const |
Overload - operator.
The quaternion soustraction is
The result is not necessarily a unit quaternion even if and are unit quaternions.
Definition at line 223 of file quaternion.cpp.
Quaternion Quaternion::operator/ | ( | const Quaternion & | q | ) | const |
Overload / operator.
Definition at line 267 of file quaternion.cpp.
Quaternion Quaternion::power | ( | const Real | t | ) | const |
Definition at line 358 of file quaternion.cpp.
ReturnMatrix Quaternion::R | ( | ) | const |
Rotation matrix from a unit quaternion.
where is a vector, a rotation matrix and q quaternion. The rotation matrix obtained from a quaternion is then
where is the cross product matrix defined by
Definition at line 458 of file quaternion.cpp.
Real Quaternion::s | ( | ) | const [inline] |
Return scalar part.
Definition at line 119 of file quaternion.h.
void Quaternion::set_s | ( | const Real | s | ) | [inline] |
Set scalar part.
Definition at line 120 of file quaternion.h.
void Quaternion::set_v | ( | const ColumnVector & | v | ) |
ReturnMatrix Quaternion::T | ( | ) | const |
Transformation matrix from a quaternion.
See Quaternion::R() for equations.
Definition at line 499 of file quaternion.cpp.
Quaternion & Quaternion::unit | ( | ) |
Normalize a quaternion.
Definition at line 311 of file quaternion.cpp.
ReturnMatrix Quaternion::v | ( | ) | const [inline] |
Return vector part.
Definition at line 121 of file quaternion.h.
Real Quaternion::s_ [private] |
Quaternion scalar part.
Definition at line 127 of file quaternion.h.
ColumnVector Quaternion::v_ [private] |
Quaternion vector part.
Definition at line 128 of file quaternion.h.