Quaternion class definition. More...
#include <quaternion.h>
Public Member Functions | |
Quaternion | conjugate () const |
Conjugate. More... | |
Quaternion | dot (const ColumnVector &w, const short sign) const |
Quaternion time derivative. More... | |
Real | dot_prod (const Quaternion &q) const |
Quaternion dot product. More... | |
ReturnMatrix | E (const short sign) const |
Matrix E. More... | |
Quaternion | exp () const |
Exponential of a quaternion. More... | |
Quaternion | i () const |
Quaternion inverse.
where and are the quaternion conjugate and the quaternion norm respectively. More... | |
Quaternion | Log () const |
Logarithm of a unit quaternion. More... | |
Real | norm () const |
Return the quaternion norm. More... | |
Quaternion | operator* (const Quaternion &q) const |
Overload * operator. More... | |
Quaternion | operator+ (const Quaternion &q) const |
Overload + operator. More... | |
Quaternion | operator- (const Quaternion &q) const |
Overload - operator. More... | |
Quaternion | operator/ (const Quaternion &q) const |
Overload / operator. More... | |
Quaternion | power (const Real t) const |
Quaternion () | |
Constructor. More... | |
Quaternion (const Real angle_in_rad, const ColumnVector &axis) | |
Constructor. More... | |
Quaternion (const Real s, const Real v1, const Real v2, const Real v3) | |
Constructor. More... | |
Quaternion (const Matrix &R) | |
Constructor. More... | |
ReturnMatrix | R () const |
Rotation matrix from a unit quaternion. More... | |
Real | s () const |
Return scalar part. More... | |
void | set_s (const Real s) |
Set scalar part. More... | |
void | set_v (const ColumnVector &v) |
Set vector part. More... | |
ReturnMatrix | T () const |
Transformation matrix from a quaternion. More... | |
Quaternion & | unit () |
Normalize a quaternion. More... | |
ReturnMatrix | v () const |
Return vector part. More... | |
Private Attributes | |
Real | s_ |
Quaternion scalar part. More... | |
ColumnVector | v_ |
Quaternion vector part. More... | |
Quaternion class definition.
Definition at line 92 of file quaternion.h.
Quaternion::Quaternion | ( | ) |
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.
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.
|
inline |
Return scalar part.
Definition at line 119 of file quaternion.h.
|
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.
|
inline |
Return vector part.
Definition at line 121 of file quaternion.h.
|
private |
Quaternion scalar part.
Definition at line 127 of file quaternion.h.
|
private |
Quaternion vector part.
Definition at line 128 of file quaternion.h.