ROBOOP, A Robotics Object Oriented Package in C++
|
Quaternion class definition. More...
#include <quaternion.h>
Public Member Functions | |
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. 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. | |
Quaternion | conjugate () const |
Conjugate. More... | |
Quaternion | i () const |
Quaternion inverse.
where and are the quaternion conjugate and the quaternion norm respectively. | |
Quaternion & | unit () |
Normalize a quaternion. | |
Quaternion | exp () const |
Exponential of a quaternion. More... | |
Quaternion | power (const Real t) const |
Quaternion | Log () const |
Logarithm of a unit quaternion. More... | |
Quaternion | dot (const ColumnVector &w, const short sign) const |
Quaternion time derivative. More... | |
ReturnMatrix | E (const short sign) const |
Matrix E. More... | |
Real | norm () const |
Return the quaternion norm. More... | |
Real | dot_prod (const Quaternion &q) const |
Quaternion dot product. More... | |
Real | s () const |
Return scalar part. | |
void | set_s (const Real s) |
Set scalar part. | |
ReturnMatrix | v () const |
Return vector part. | |
void | set_v (const ColumnVector &v) |
Set vector part. More... | |
ReturnMatrix | R () const |
Rotation matrix from a unit quaternion. More... | |
ReturnMatrix | T () const |
Transformation matrix from a quaternion. More... | |
Private Attributes | |
Real | s_ |
Quaternion scalar part. | |
ColumnVector | v_ |
Quaternion vector part. | |
Quaternion class definition.
Definition at line 89 of file quaternion.h.
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 117 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 385 of file quaternion.cpp.
References s_, sign(), and v_.
Referenced by Impedance::control().
Real Quaternion::dot_prod | ( | const Quaternion & | q | ) | const |
Quaternion dot product.
The dot product of quaternion is defined by
Definition at line 442 of file quaternion.cpp.
Referenced by Slerp(), Slerp_prime(), and Resolved_acc::torque_cmd().
ReturnMatrix Quaternion::E | ( | const short | sign | ) | const |
Matrix E.
See Quaternion::dot for explanation.
Definition at line 423 of file quaternion.cpp.
References sign(), threebythreeident, and x_prod_matrix().
Referenced by Omega().
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 333 of file quaternion.cpp.
Referenced by Spl_Quaternion::quat(), and Spl_Quaternion::quat_w().
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 362 of file quaternion.cpp.
Real Quaternion::norm | ( | ) | const |
Return the quaternion norm.
The norm of quaternion is defined by
Definition at line 295 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 240 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 200 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 220 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 455 of file quaternion.cpp.
References threebythreeident, and x_prod_matrix().
Referenced by Dynamics::set_robot_on_first_point_of_splines().
void Quaternion::set_v | ( | const ColumnVector & | v | ) |
Set vector part.
Set quaternion vector part.
Definition at line 271 of file quaternion.cpp.
Referenced by Integ_quat(), Integ_Trap_quat_v(), operator*(), and operator/().
ReturnMatrix Quaternion::T | ( | ) | const |
Transformation matrix from a quaternion.
See Quaternion::R() for equations.
Definition at line 496 of file quaternion.cpp.
References fourbyfourident, and x_prod_matrix().