Public Member Functions | Private Attributes
Quaternion Class Reference

Quaternion class definition. More...

#include <quaternion.h>

List of all members.

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.

\[ q^{-1} = \frac{q^{*}}{N(q)} \]

where $q^{*}$ and $N(q)$ 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.
Quaternionunit ()
 Normalize a quaternion.
ReturnMatrix v () const
 Return vector part.

Private Attributes

Real s_
 Quaternion scalar part.
ColumnVector v_
 Quaternion vector part.

Detailed Description

Quaternion class definition.

Definition at line 92 of file quaternion.h.


Constructor & Destructor Documentation

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())

\[ R(s,v) = \left[ \begin{array}{ccc} s^2+v_1^2-v_2^2-v_3^2 & 2v_1v_2+2sv_3 & 2v_1v_3-2sv_2 \\ 2v_1v_2-2sv_3 & s^2-v_1^2+v_2^2-v_3^2 & 2v_2v_3+2sv_1 \\ 2v_1v_3+2sv_2 &2v_2v_3-2sv_1 & s^2-v_1^2-v_2^2+v_3^2 \end{array} \right] \]

First we find $s$:

\[ R_{11} + R_{22} + R_{33} + R_{44} = 4s^2 \]

Now the other values are:

\[ s = \pm \frac{1}{2}\sqrt{R_{11} + R_{22} + R_{33} + R_{44}} \]

\[ v_1 = \frac{R_{32}-R_{23}}{4s} \]

\[ v_2 = \frac{R_{13}-R_{31}}{4s} \]

\[ v_3 = \frac{R_{21}-R_{12}}{4s} \]

The sign of $s$ cannot be determined. Depending on the choice of the sign for s the sign of $v$ change as well. Thus the quaternions $q$ and $-q$ 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.


Member Function Documentation

Conjugate.

The conjugate of a quaternion $q = [s, v]$ is $q^{*} = [s, -v]$

Definition at line 283 of file quaternion.cpp.

Quaternion Quaternion::dot ( const ColumnVector &  w,
const short  sign 
) const

Quaternion time derivative.

The quaternion time derivative, quaternion propagation equation, is

\[ \dot{s} = - \frac{1}{2}v^Tw_{_0} \]

\[ \dot{v} = \frac{1}{2}E(s,v)w_{_0} \]

\[ E = sI - S(v) \]

where $w_{_0}$ is the angular velocity vector expressed in the base frame. If the vector is expressed in the object frame, $w_{_b}$, the time derivative becomes

\[ \dot{s} = - \frac{1}{2}v^Tw_{_b} \]

\[ \dot{v} = \frac{1}{2}E(s,v)w_{_b} \]

\[ E = sI + S(v) \]

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

\[ q_1\cdot q_2 = s_1s_2 + v_1 \cdot v_2 \]

Definition at line 445 of file quaternion.cpp.

ReturnMatrix Quaternion::E ( const short  sign) const

Matrix E.

See Quaternion::dot for explanation.

Definition at line 426 of file quaternion.cpp.

Exponential of a quaternion.

Let a quaternion of the form $q = [0, \theta v]$, q is not necessarily a unit quaternion. Then the exponential function is defined by $q = [\cos(\theta),v \sin(\theta)]$.

Definition at line 336 of file quaternion.cpp.

Quaternion inverse.

\[ q^{-1} = \frac{q^{*}}{N(q)} \]

where $q^{*}$ and $N(q)$ are the quaternion conjugate and the quaternion norm respectively.

Definition at line 323 of file quaternion.cpp.

Logarithm of a unit quaternion.

The logarithm function of a unit quaternion $q = [\cos(\theta), v \sin(\theta)]$ is defined as $log(q) = [0, v\theta]$. The result is not necessary a unit quaternion.

Definition at line 365 of file quaternion.cpp.

Return the quaternion norm.

The norm of quaternion is defined by

\[ N(q) = s^2 + v\cdot v \]

Definition at line 298 of file quaternion.cpp.

Quaternion Quaternion::operator* ( const Quaternion rhs) const

Overload * operator.

The multiplication of two quaternions is

\[ q = q_1q_2 = [s_1s_2 - v_1\cdot v_2, v_1 \times v_2 + s_1v_2 + s_2v_1] \]

where $\cdot$ and $\times$ denote the scalar and vector product in $R^3$ respectively.

If $q_1$ and $q_2$ 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

\[ q_1 + q_2 = [s_1, v_1] + [s_2, v_2] = [s_1+s_2, v_1+v_2] \]

The result is not necessarily a unit quaternion even if $q_1$ and $q_2$ are unit quaternions.

Definition at line 203 of file quaternion.cpp.

Quaternion Quaternion::operator- ( const Quaternion rhs) const

Overload - operator.

The quaternion soustraction is

\[ q_1 - q_2 = [s_1, v_1] - [s_2, v_2] = [s_1-s_2, v_1-v_2] \]

The result is not necessarily a unit quaternion even if $q_1$ and $q_2$ 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.

$p'=qpq^{-1} = Rp$ where $p$ is a vector, $R$ a rotation matrix and $q$ q quaternion. The rotation matrix obtained from a quaternion is then

\[ R(s,v) = (s^2 - v^Tv)I + 2vv^T - 2s S(v) \]

\[ R(s,v) = \left[ \begin{array}{ccc} s^2+v_1^2-v_2^2-v_3^2 & 2v_1v_2+2sv_3 & 2v_1v_3-2sv_2 \\ 2v_1v_2-2sv_3 & s^2-v_1^2+v_2^2-v_3^2 & 2v_2v_3+2sv_1 \\ 2v_1v_3+2sv_2 &2v_2v_3-2sv_1 & s^2-v_1^2-v_2^2+v_3^2 \end{array} \right] \]

where $S(\cdot)$ is the cross product matrix defined by

\[ S(u) = \left[ \begin{array}{ccc} 0 & -u_3 & u_2 \\ u_3 &0 & -u_1 \\ -u_2 & u_1 & 0 \\ \end{array} \right] \]

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)

Set vector part.

Set quaternion vector part.

Definition at line 274 of file quaternion.cpp.

ReturnMatrix Quaternion::T ( ) const

Transformation matrix from a quaternion.

See Quaternion::R() for equations.

Definition at line 499 of file quaternion.cpp.

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.


Member Data Documentation

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.


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


kni
Author(s): Martin Günther
autogenerated on Mon Aug 14 2017 02:44:13