maliput
|
A Quaternion representation.
#include <include/maliput/math/quaternion.h>
Public Member Functions | |
MALIPUT_DEFAULT_COPY_AND_MOVE_AND_ASSIGN (Quaternion) | |
Quaternion () | |
Constructs a Quaternion initialized to \( 1+0i+0j+0k \). More... | |
Quaternion (double w, double x, double y, double z) | |
Constructs a Quaternion and initializes it to \( w+xi+yj+zk \). More... | |
Quaternion (double angle, const Vector3 &axis) | |
Constructs a Quaternion expressed by angle rotation around axis vector. More... | |
Quaternion (const Vector4 &coeffs) | |
Constructs a Quaternion from a 4D vector matching all its components. More... | |
Quaternion (const Matrix3 &rotation_matrix) | |
Constructs a Quaternion from a 3D rotation matrix. More... | |
double | w () const |
double | x () const |
double | y () const |
double | z () const |
double & | w () |
double & | x () |
double & | y () |
double & | z () |
Vector3 | vec () const |
}@ More... | |
Vector4 | coeffs () const |
Quaternion & | set_identity () |
Sets the identity quaternion values as if it was initialized with \( [1, 0, 0, 0] \). More... | |
double | squared_norm () const |
double | norm () const |
void | normalize () |
Normalizes (norm() == 1) this quaternion coefficients. More... | |
Quaternion | normalized () const |
double | dot (const Quaternion &other) const |
Executes the dot product between this quaternion coefficients and other . More... | |
double | AngularDistance (const Quaternion &other) const |
Computes the angular distance between the rotation of this quaternion and other . More... | |
Matrix3 | ToRotationMatrix () const |
void | SetFromTwoVectors (const Vector3 &a, const Vector3 &b) |
Sets this quaternion with the coefficients that makes a transform into b . More... | |
Quaternion | operator* (const Quaternion &q) const |
Product operator overload. More... | |
Quaternion & | operator*= (const Quaternion &q) |
Product and assignment operator overload. More... | |
Vector3 | operator* (const Vector3 &v) const |
Forwards the call to TransformVector(v) . More... | |
bool | operator== (const Quaternion &other) const |
Operator equal to overload. More... | |
bool | operator!= (const Quaternion &other) const |
Operator not equal to overload. More... | |
Quaternion | Inverse () const |
Quaternion | conjugate () const |
Quaternion | Slerp (double t, const Quaternion &other) const |
bool | IsApprox (const Quaternion &other, double precision) const |
Evaluates if this quaternion is almost equal to other up to precision tolerance. More... | |
Vector3 | TransformVector (const Vector3 &v) const |
Applies this quaternion transformation to v 3D vector. More... | |
Static Public Member Functions | |
static Quaternion | Identity () |
static Quaternion | FromTwoVectors (const Vector3 &a, const Vector3 &b) |
Static Public Attributes | |
static constexpr double | kTolerance {1e-15} |
Quaternion | ( | ) |
Constructs a Quaternion initialized to \( 1+0i+0j+0k \).
Quaternion | ( | double | w, |
double | x, | ||
double | y, | ||
double | z | ||
) |
Constructs a Quaternion and initializes it to \( w+xi+yj+zk \).
w | The real \( w \) coefficient. |
x | The internal \( x \) coefficient. |
y | The internal \( y \) coefficient. |
z | The internal \( z \)s coefficient. |
Quaternion | ( | double | angle, |
const Vector3 & | axis | ||
) |
Constructs a Quaternion expressed by angle
rotation around axis
vector.
angle | A scalar representing an angle in radians. |
axis | A 3D vector representing the rotation angle. |
|
explicit |
Constructs a Quaternion from a 4D vector matching all its components.
coeffs | A 4D vector whose first element is \( w \), second element is \( x \), third element is \( y \) and fourth element is \( z \). |
|
explicit |
Constructs a Quaternion from a 3D rotation matrix.
rotation_matrix | A 3x3 matrix whose elements represent a rotation matrix. |
double AngularDistance | ( | const Quaternion & | other | ) | const |
Computes the angular distance between the rotation of this quaternion and other
.
other | A Quaternion. |
this
rotation and other
's rotation. Vector4 coeffs | ( | ) | const |
Quaternion conjugate | ( | ) | const |
this
. double dot | ( | const Quaternion & | other | ) | const |
Executes the dot product between this quaternion coefficients and other
.
other | A Quaternion. |
other
.
|
static |
|
static |
Quaternion Inverse | ( | ) | const |
bool IsApprox | ( | const Quaternion & | other, |
double | precision | ||
) | const |
Evaluates if this quaternion is almost equal to other
up to precision
tolerance.
this
quaternion is approximately equal to other
when the squared norm of the vector difference from both quaternion's coefficients is smaller than the minimum squared norm between this
and other
scaled with the squared precision.
other | A Quaternion to compare with. |
precision | The tolerance. |
other
up to precision
tolerance. MALIPUT_DEFAULT_COPY_AND_MOVE_AND_ASSIGN | ( | Quaternion | ) |
double norm | ( | ) | const |
void normalize | ( | ) |
Normalizes (norm()
== 1) this quaternion coefficients.
When the norm()
< kTolerance
, the result is equivalent to call set_identity()
.
Quaternion normalized | ( | ) | const |
*this
quaternion with normalized coefficients. bool operator!= | ( | const Quaternion & | other | ) | const |
Operator not equal to overload.
Performs a coefficient wise comparison.
other | A quaternion to compare to this quaternion. |
this
' and other
's coefficients are not equal. Quaternion operator* | ( | const Quaternion & | q | ) | const |
Product operator overload.
q | A Quaternion. |
Quaternion & operator*= | ( | const Quaternion & | q | ) |
Product and assignment operator overload.
q | A Quaternion. |
*this
initialized with \( `this` * `q` \). bool operator== | ( | const Quaternion & | other | ) | const |
Operator equal to overload.
Performs a coefficient wise comparison.
other | A quaternion to compare to this quaternion. |
this
' and other
's coefficients are equal. Quaternion& set_identity | ( | ) |
Sets the identity quaternion values as if it was initialized with \( [1, 0, 0, 0] \).
*this
. Sets this quaternion with the coefficients that makes a
transform into b
.
a | A 3D vector. |
b | A 3D vector. |
Quaternion Slerp | ( | double | t, |
const Quaternion & | other | ||
) | const |
*this
and other
at the parameter t
.t | The interpolation parameter. It must be in [0; 1]. |
other | A quaternion. |
double squared_norm | ( | ) | const |
Matrix3 ToRotationMatrix | ( | ) | const |
Applies this quaternion transformation to v
3D vector.
v | A 3D vector. |
Vector3 vec | ( | ) | const |
}@
double& w | ( | ) |
double w | ( | ) | const |
double& x | ( | ) |
double x | ( | ) | const |
double& y | ( | ) |
double y | ( | ) | const |
double& z | ( | ) |
double z | ( | ) | const |
|
staticconstexpr |