Biorbd
|
#include <Quaternion.h>
Public Member Functions | |
Quaternion (double kStabilizer=1) | |
Construct Quaternion. More... | |
Quaternion (const biorbd::utils::Quaternion &other) | |
Construct Quaternion from another quaternion. More... | |
Quaternion (const RigidBodyDynamics::Math::Vector4d &vec4, double kStabilizer=1) | |
Construct Quaternion. More... | |
Quaternion (const biorbd::utils::Scalar &w, const biorbd::utils::Scalar &x, const biorbd::utils::Scalar &y, const biorbd::utils::Scalar &z, double kStabilizer=1) | |
Construct Quaternion. More... | |
Quaternion (const biorbd::utils::Scalar &w, const biorbd::utils::Vector3d &vec3, double kStabilizer=1) | |
Construct Quaternion. More... | |
biorbd::utils::Scalar | w () const |
Return the real part (w) the Quaternion. More... | |
biorbd::utils::Scalar | x () const |
Return the X-Component of the imaginary part of the Quaternion. More... | |
biorbd::utils::Scalar | y () const |
Return the Y-Component of the imaginary part of the Quaternion. More... | |
biorbd::utils::Scalar | z () const |
Return the Z-Component of the imaginary part of the Quaternion. More... | |
void | setKStab (double newKStab) |
Set the k stabilizer. More... | |
double | kStab () const |
Return the k stabilizer. More... | |
biorbd::utils::Quaternion | operator* (const biorbd::utils::Quaternion &other) const |
Quaternion multiplication. More... | |
biorbd::utils::Quaternion | operator* (const biorbd::utils::Scalar &scalar) const |
Multiply the quaternion with a scalar. More... | |
biorbd::utils::Quaternion | operator* (float scalar) const |
Multiply the quaternion with a scalar. More... | |
biorbd::utils::Quaternion | operator+ (const biorbd::utils::Quaternion &other) const |
Add the quaternion to another. More... | |
biorbd::utils::Quaternion | operator- (const biorbd::utils::Quaternion &other) const |
Subtract the quaternion to another. More... | |
biorbd::utils::Rotation | toMatrix (bool skipAsserts=false) const |
Convert the quaternion to a RotoTrans. More... | |
biorbd::utils::Quaternion | slerp (double alpha, const Quaternion &quat) const |
Interpolation of the quaternion between to position. More... | |
biorbd::utils::Quaternion | conjugate () const |
Return the conjugate of the quaternion. More... | |
biorbd::utils::Quaternion | timeStep (const biorbd::utils::Vector3d &omega, double dt) |
Integrate the quaternion from its velocity. More... | |
biorbd::utils::Vector3d | rotate (const biorbd::utils::Vector3d &vec) const |
Return a rotated vector from the quaternion. More... | |
biorbd::utils::Quaternion | omegaToQDot (const biorbd::utils::Vector3d &omega) const |
Converts a 3d angular velocity vector. More... | |
biorbd::utils::Vector3d | eulerDotToOmega (const biorbd::utils::Vector3d &eulerDot, const biorbd::utils::Vector3d &euler, const biorbd::utils::String &seq) |
Converts a 3d angular velocity vector. More... | |
void | derivate (const biorbd::utils::Vector &w) |
Return the time derivative of the quaterion. More... | |
void | normalize () |
Force the normalization of the quaternion. More... | |
Static Public Member Functions | |
static biorbd::utils::Quaternion | fromGLRotate (const biorbd::utils::Scalar &angle, const biorbd::utils::Scalar &x, const biorbd::utils::Scalar &y, const biorbd::utils::Scalar &z, double kStab=1) |
Construct Quaternion from a GL. More... | |
static biorbd::utils::Quaternion | fromAxisAngle (const biorbd::utils::Scalar &angle, const biorbd::utils::Vector3d &axis, double kStab=1) |
Construct Quaternion from an axis angle. More... | |
static biorbd::utils::Quaternion | fromMatrix (const biorbd::utils::RotoTrans &rt, double kStab=1) |
Construct Quaternion from a RotoTrans matrix. More... | |
static biorbd::utils::Quaternion | fromMatrix (const biorbd::utils::Rotation &mat, double kStab=1) |
Construct Quaternion from a Rotation matrix. More... | |
static biorbd::utils::Quaternion | fromZYXAngles (const biorbd::utils::Vector3d &zyx_angles, double kStab=1) |
Construct Quaternion from Euler angles (sequece ZYX) More... | |
static biorbd::utils::Quaternion | fromYXZAngles (const biorbd::utils::Vector3d &yxz_angles, double kStab=1) |
Construct Quaternion from Euler angles (sequece YXZ) More... | |
static biorbd::utils::Quaternion | fromXYZAngles (const biorbd::utils::Vector3d &xyz_angles, double kStab=1) |
Construct Quaternion from Euler angles (sequece XYZ) More... | |
Protected Attributes | |
double | m_Kstab |
Stabilization factor for the derivation. | |
Description of a quaternion in the format (w, x, y, z)
The definition for conversions are taken from https://www.euclideanspace.com/maths/geometry/rotations/conversions/index.htm
Definition at line 26 of file Quaternion.h.
biorbd::utils::Quaternion::Quaternion | ( | double | kStabilizer = 1 | ) |
Construct Quaternion.
kStabilizer | The value of the kstabilizer |
Definition at line 10 of file Quaternion.cpp.
biorbd::utils::Quaternion::Quaternion | ( | const biorbd::utils::Quaternion & | other | ) |
Construct Quaternion from another quaternion.
other | Other quaternion |
Definition at line 17 of file Quaternion.cpp.
biorbd::utils::Quaternion::Quaternion | ( | const RigidBodyDynamics::Math::Vector4d & | vec4, |
double | kStabilizer = 1 |
||
) |
Construct Quaternion.
vec4 | The vector describing the quaternion |
kStabilizer | The value of the kstabilizer |
Definition at line 24 of file Quaternion.cpp.
biorbd::utils::Quaternion::Quaternion | ( | const biorbd::utils::Scalar & | w, |
const biorbd::utils::Scalar & | x, | ||
const biorbd::utils::Scalar & | y, | ||
const biorbd::utils::Scalar & | z, | ||
double | kStabilizer = 1 |
||
) |
Construct Quaternion.
w | The W-Component of quaternion |
x | The X-Component of quaternion |
y | The Y-Component of quaternion |
z | The Z-Component of quaternion |
kStabilizer | The value of the kstabilizer |
Definition at line 33 of file Quaternion.cpp.
biorbd::utils::Quaternion::Quaternion | ( | const biorbd::utils::Scalar & | w, |
const biorbd::utils::Vector3d & | vec3, | ||
double | kStabilizer = 1 |
||
) |
Construct Quaternion.
w | The W-Component of quaternion |
vec3 | The vector describing the imaginary part |
kStabilizer | The value of the kstabilizer |
Definition at line 44 of file Quaternion.cpp.
biorbd::utils::Quaternion biorbd::utils::Quaternion::conjugate | ( | ) | const |
Return the conjugate of the quaternion.
Definition at line 260 of file Quaternion.cpp.
void biorbd::utils::Quaternion::derivate | ( | const biorbd::utils::Vector & | w | ) |
Return the time derivative of the quaterion.
w | The vector of time derivative (output) |
Definition at line 317 of file Quaternion.cpp.
biorbd::utils::Vector3d biorbd::utils::Quaternion::eulerDotToOmega | ( | const biorbd::utils::Vector3d & | eulerDot, |
const biorbd::utils::Vector3d & | euler, | ||
const biorbd::utils::String & | seq | ||
) |
Converts a 3d angular velocity vector.
eulerDot | the Euler angle rates |
euler | the Euler angles |
seq | the Euler angles sequence |
Converts a 3d angular velocity vector expressed in terms of euler angles rate into the 3d angular velocity vector expressed in the fixed parent frame. See https://davidbrown3.github.io/2017-07-25/EulerAngles/ for correct equations.
Definition at line 298 of file Quaternion.cpp.
|
static |
Construct Quaternion from an axis angle.
angle | The angle in radians |
axis | The 3d vector of the axis |
kStab | The value of the kstabilizer |
Definition at line 142 of file Quaternion.cpp.
|
static |
Construct Quaternion from a GL.
angle | The angle in radians |
x | The X-Component of quaternion |
y | The Y-Component of quaternion |
z | The Z-Component of quaternion |
kStab | The value of the kstabilizer |
Definition at line 130 of file Quaternion.cpp.
|
static |
Construct Quaternion from a Rotation matrix.
mat | The rotation matrix |
kStab | The value of the kstabilizer |
Definition at line 161 of file Quaternion.cpp.
|
static |
Construct Quaternion from a RotoTrans matrix.
rt | RotoTrans matrix |
kStab | The value of the kstabilizer |
Definition at line 155 of file Quaternion.cpp.
|
static |
Construct Quaternion from Euler angles (sequece XYZ)
xyz_angles | The Euler angles in a sequence where the first element is the X-component |
kStab | The value of the kstabilizer |
Definition at line 189 of file Quaternion.cpp.
|
static |
Construct Quaternion from Euler angles (sequece YXZ)
yxz_angles | The Euler angles in a sequence where the first element is the Y-component |
kStab | The value of the kstabilizer |
Definition at line 181 of file Quaternion.cpp.
|
static |
Construct Quaternion from Euler angles (sequece ZYX)
zyx_angles | The Euler angles in a sequence where the first element is the Z-component |
kStab | The value of the kstabilizer |
Definition at line 173 of file Quaternion.cpp.
double biorbd::utils::Quaternion::kStab | ( | ) | const |
Return the k stabilizer.
The k statilizer value is used during several operation to make the quaternion tending toward a norm of
Definition at line 75 of file Quaternion.cpp.
void biorbd::utils::Quaternion::normalize | ( | ) |
Force the normalization of the quaternion.
Definition at line 353 of file Quaternion.cpp.
biorbd::utils::Quaternion biorbd::utils::Quaternion::omegaToQDot | ( | const biorbd::utils::Vector3d & | omega | ) | const |
Converts a 3d angular velocity vector.
omega | the angular velocity |
Converts a 3d angular velocity vector into a 4d derivative of the components of the quaternion
Definition at line 287 of file Quaternion.cpp.
biorbd::utils::Quaternion biorbd::utils::Quaternion::operator* | ( | const biorbd::utils::Quaternion & | other | ) | const |
Quaternion multiplication.
other | The other quaternion |
Definition at line 80 of file Quaternion.cpp.
biorbd::utils::Quaternion biorbd::utils::Quaternion::operator* | ( | const biorbd::utils::Scalar & | scalar | ) | const |
Multiply the quaternion with a scalar.
scalar | The scalar to multiply with |
Definition at line 91 of file Quaternion.cpp.
biorbd::utils::Quaternion biorbd::utils::Quaternion::operator* | ( | float | scalar | ) | const |
Multiply the quaternion with a scalar.
scalar | The scalar to multiply with |
Definition at line 98 of file Quaternion.cpp.
biorbd::utils::Quaternion biorbd::utils::Quaternion::operator+ | ( | const biorbd::utils::Quaternion & | other | ) | const |
Add the quaternion to another.
other | The other quaternion to add |
Definition at line 116 of file Quaternion.cpp.
biorbd::utils::Quaternion biorbd::utils::Quaternion::operator- | ( | const biorbd::utils::Quaternion & | other | ) | const |
Subtract the quaternion to another.
other | Other quaternion to substract |
Definition at line 123 of file Quaternion.cpp.
biorbd::utils::Vector3d biorbd::utils::Quaternion::rotate | ( | const biorbd::utils::Vector3d & | vec | ) | const |
Return a rotated vector from the quaternion.
vec | The vector to rotate |
Definition at line 276 of file Quaternion.cpp.
void biorbd::utils::Quaternion::setKStab | ( | double | newKStab | ) |
Set the k stabilizer.
newKStab | The new value |
Definition at line 70 of file Quaternion.cpp.
biorbd::utils::Quaternion biorbd::utils::Quaternion::slerp | ( | double | alpha, |
const Quaternion & | quat | ||
) | const |
Interpolation of the quaternion between to position.
alpha | The proportion of the rotation |
quat | The quaternion to targe |
Definition at line 219 of file Quaternion.cpp.
biorbd::utils::Quaternion biorbd::utils::Quaternion::timeStep | ( | const biorbd::utils::Vector3d & | omega, |
double | dt | ||
) |
Integrate the quaternion from its velocity.
omega | 3D vector of the angular velocity |
dt | The time step to intergrate on |
Definition at line 268 of file Quaternion.cpp.
biorbd::utils::Rotation biorbd::utils::Quaternion::toMatrix | ( | bool | skipAsserts = false | ) | const |
Convert the quaternion to a RotoTrans.
skipAsserts | Check if the norm of the quaternion is approximately 1 |
The function throws a runtime_error if the skipAsserts is false and the norm of the quaternion is not almost one. In order to accelerate the computation of the norm, the norm-squared is evaluated. The threshold is 1e-10 for the norm-squared
Definition at line 197 of file Quaternion.cpp.
biorbd::utils::Scalar biorbd::utils::Quaternion::w | ( | ) | const |
Return the real part (w) the Quaternion.
Definition at line 53 of file Quaternion.cpp.
biorbd::utils::Scalar biorbd::utils::Quaternion::x | ( | ) | const |
Return the X-Component of the imaginary part of the Quaternion.
Definition at line 57 of file Quaternion.cpp.
biorbd::utils::Scalar biorbd::utils::Quaternion::y | ( | ) | const |
Return the Y-Component of the imaginary part of the Quaternion.
Definition at line 61 of file Quaternion.cpp.
biorbd::utils::Scalar biorbd::utils::Quaternion::z | ( | ) | const |
Return the Z-Component of the imaginary part of the Quaternion.
Definition at line 65 of file Quaternion.cpp.