GAMS
1.4.0
|
Used internally to implement angle operations. More...
#include <Quaternion.h>
Public Member Functions | |
constexpr | Quaternion () |
Default constructor. More... | |
Quaternion (const OrientationVector &rot) | |
Constructor which converts a orientation vector into the corresponding quaternion representation. More... | |
Quaternion (const PositionVector &loc) | |
Constructor which converts a position vector into the corresponding quaternion representation; x, y, and z are copied over. More... | |
Quaternion (double rx, double ry, double rz) | |
Constructor which converts a orientation vector, specified in individual terms, into the corresponding quaternion representation. More... | |
constexpr | Quaternion (double x, double y, double z, double w) |
Primary constructor. More... | |
double | angle_to (const Quaternion &target) const |
Calculates the angle between the orientations represented by this, and the target Quaternion. More... | |
Quaternion & | conjugate () |
Conjugate this quaternion in-place; may use in place of invert for unit quaternions for better performance. More... | |
double | dot_product (const Quaternion &rhs) const |
Calculates the Quaternion dot product between this, and the right-hand-side; this is the inner-product, over the product of the magnitude of both sides. More... | |
Quaternion | exp () const |
Calculate e to the power of this quaternion, return result as new quaternion. More... | |
void | exp_this () |
Calculate e to the power of this quaternion, store result in this quaternion. More... | |
void | from_angular_vector (const OrientationVector &rot) |
void | from_angular_vector (double rx, double ry, double rz) |
void | from_linear_vector (const PositionVector &loc) |
void | from_linear_vector (double x, double y, double z) |
double | imag () const |
Returns the magnitude of imaginary part of this quaternion. More... | |
double | inner_product (const Quaternion &rhs) const |
Calculates the Quaternion inner-product between this, and the right-hand-side, which is the sum of the pair-wise multiplication of each corresponding term of the Quaternions. More... | |
void | invert () |
Inverts this quaternion to its reciprical. More... | |
Quaternion | ln () const |
Calculate the natural log of this quaternion, return result in a new quaternion. More... | |
void | ln_this () |
Calculate natural log of this quaternion, store result in this quaternion. More... | |
double | m11 () const |
Row 1 Column 1 of orientation matrix equivalent to this quaternion. More... | |
double | m12 () const |
Row 1 Column 2 of orientation matrix equivalent to this quaternion. More... | |
double | m13 () const |
Row 1 Column 3 of orientation matrix equivalent to this quaternion. More... | |
double | m21 () const |
Row 2 Column 1 of orientation matrix equivalent to this quaternion. More... | |
double | m22 () const |
Row 2 Column 2 of orientation matrix equivalent to this quaternion. More... | |
double | m23 () const |
Row 2 Column 3 of orientation matrix equivalent to this quaternion. More... | |
double | m31 () const |
Row 3 Column 1 of orientation matrix equivalent to this quaternion. More... | |
double | m32 () const |
Row 3 Column 2 of orientation matrix equivalent to this quaternion. More... | |
double | m33 () const |
Row 3 Column 3 of orientation matrix equivalent to this quaternion. More... | |
double | mag () const |
Returns the magnitude of this quaternion. More... | |
double | mag_squared () const |
Returns the magnitude of this quaternion, squared. More... | |
Quaternion & | negate () |
Flip the sign of all parts of the quaternion; equivalent to (but potentially faster than) this->scale(-1);. More... | |
Quaternion | operator* (const Quaternion &rhs) const |
Calculate hamilton product, this * rhs, and return new Quaternion. More... | |
Quaternion & | operator*= (const Quaternion &rhs) |
Calculate hamilton product, this * rhs, and store into this. More... | |
constexpr Quaternion | operator- () const |
Copy and conjugate this quaternion. More... | |
void | orient_by (Quaternion rot) |
Treat this quaternion as a position quaternion (w should be zero), and orient it by the orientation represented by rot. More... | |
Quaternion | pow (const Quaternion &e) const |
Calculate this quaternion raised to a quaternion power, return result in a new quaternion. More... | |
Quaternion | pow (double e) const |
Calculate this quaternion raised to a scalar power, return result in a new quaternion. More... | |
void | pow_this (const Quaternion &e) |
Calculate this quaternion raised to a quaternion power, store result in this quaternion. More... | |
void | pow_this (double e) |
Calculate this quaternion raised to a scalar power, store result in this quaternion. More... | |
void | pre_multiply (const Quaternion &lhs) |
Calculate hamilton product, lhs * this, and store into this. More... | |
void | scale (double s) |
Multiply each part of this quaternion by s. More... | |
Quaternion | slerp (const Quaternion &o, double t) |
If *this and o are unit quaternions, interpolate a quaternion that is partially between them, and return it as a new quaternion. More... | |
void | slerp_this (const Quaternion &o, double t) |
If *this and o are unit quaternions, interpolate a quaternion that is partially between them, and store it in *this. More... | |
void | to_angular_vector (double &rx, double &ry, double &rz) const |
void | to_angular_vector (OrientationVector &rot) const |
void | to_linear_vector (double &x, double &y, double &z) const |
void | to_linear_vector (PositionVector &loc) const |
constexpr double | w () const |
getter of w (or real scalar) part of quaternion More... | |
double | w (double new_w) |
setter of w (or real scalar) part of quaternion More... | |
constexpr double | x () const |
getter of x (or i) part of quaternion More... | |
double | x (double new_x) |
getter of x (or i) part of quaternion More... | |
constexpr double | y () const |
getter of y (or j) part of quaternion More... | |
double | y (double new_y) |
getter of y (or j) part of quaternion More... | |
constexpr double | z () const |
getter of z (or k) part of quaternion More... | |
double | z (double new_z) |
getter of z (or k) part of quaternion More... | |
Static Public Member Functions | |
static void | hamilton_product (Quaternion &into, const Quaternion &lhs, const Quaternion &rhs) |
Calculates the hamilton product of two quaternions, into a third. More... | |
Private Attributes | |
double | w_ |
double | x_ |
double | y_ |
double | z_ |
Used internally to implement angle operations.
Not reference-frame aware.
Definition at line 74 of file Quaternion.h.
|
inlineconstexpr |
Default constructor.
Initializes x, y, z, and w to zero.
Definition at line 80 of file Quaternion.h.
|
constexpr |
Primary constructor.
Specifies each term explicitly
gams::pose::Quaternion::Quaternion | ( | double | rx, |
double | ry, | ||
double | rz | ||
) |
Constructor which converts a orientation vector, specified in individual terms, into the corresponding quaternion representation.
See OrientationVector for details of the orientation vector representation.
|
explicit |
Constructor which converts a orientation vector into the corresponding quaternion representation.
See OrientationVector for details of the orientation vector representation.
|
explicit |
Constructor which converts a position vector into the corresponding quaternion representation; x, y, and z are copied over.
The w term is 0
double gams::pose::Quaternion::angle_to | ( | const Quaternion & | target | ) | const |
Calculates the angle between the orientations represented by this, and the target Quaternion.
This is the smallest angle this can be orientd to arrive at target.
target | the target Quaternion |
Quaternion& gams::pose::Quaternion::conjugate | ( | ) |
Conjugate this quaternion in-place; may use in place of invert for unit quaternions for better performance.
double gams::pose::Quaternion::dot_product | ( | const Quaternion & | rhs | ) | const |
Calculates the Quaternion dot product between this, and the right-hand-side; this is the inner-product, over the product of the magnitude of both sides.
rhs | the Quaternion to dot-multiply with |
Quaternion gams::pose::Quaternion::exp | ( | ) | const |
Calculate e to the power of this quaternion, return result as new quaternion.
void gams::pose::Quaternion::exp_this | ( | ) |
Calculate e to the power of this quaternion, store result in this quaternion.
void gams::pose::Quaternion::from_angular_vector | ( | const OrientationVector & | rot | ) |
void gams::pose::Quaternion::from_angular_vector | ( | double | rx, |
double | ry, | ||
double | rz | ||
) |
void gams::pose::Quaternion::from_linear_vector | ( | const PositionVector & | loc | ) |
void gams::pose::Quaternion::from_linear_vector | ( | double | x, |
double | y, | ||
double | z | ||
) |
|
static |
Calculates the hamilton product of two quaternions, into a third.
The resulting quaternion represents the composed orientation of the args. The target quaternion can be one of the two source quaternion. The two source quaternions can be the same (for squaring)
into | destination quaternion; will be overwritten |
lhs | left-hand-side source quaternion (non-commutative) |
rhs | right-hand-side source quaternion (non-commutative) |
double gams::pose::Quaternion::imag | ( | ) | const |
Returns the magnitude of imaginary part of this quaternion.
double gams::pose::Quaternion::inner_product | ( | const Quaternion & | rhs | ) | const |
Calculates the Quaternion inner-product between this, and the right-hand-side, which is the sum of the pair-wise multiplication of each corresponding term of the Quaternions.
Note that unlike hamilton_product, this is commutative.
rhs | the Quaternion to multiply with |
void gams::pose::Quaternion::invert | ( | ) |
Inverts this quaternion to its reciprical.
Equivalent to (but slower than) conjugate if you know this quaternion is a unit quaternion.
Quaternion gams::pose::Quaternion::ln | ( | ) | const |
Calculate the natural log of this quaternion, return result in a new quaternion.
void gams::pose::Quaternion::ln_this | ( | ) |
Calculate natural log of this quaternion, store result in this quaternion.
double gams::pose::Quaternion::m11 | ( | ) | const |
Row 1 Column 1 of orientation matrix equivalent to this quaternion.
double gams::pose::Quaternion::m12 | ( | ) | const |
Row 1 Column 2 of orientation matrix equivalent to this quaternion.
double gams::pose::Quaternion::m13 | ( | ) | const |
Row 1 Column 3 of orientation matrix equivalent to this quaternion.
double gams::pose::Quaternion::m21 | ( | ) | const |
Row 2 Column 1 of orientation matrix equivalent to this quaternion.
double gams::pose::Quaternion::m22 | ( | ) | const |
Row 2 Column 2 of orientation matrix equivalent to this quaternion.
double gams::pose::Quaternion::m23 | ( | ) | const |
Row 2 Column 3 of orientation matrix equivalent to this quaternion.
double gams::pose::Quaternion::m31 | ( | ) | const |
Row 3 Column 1 of orientation matrix equivalent to this quaternion.
double gams::pose::Quaternion::m32 | ( | ) | const |
Row 3 Column 2 of orientation matrix equivalent to this quaternion.
double gams::pose::Quaternion::m33 | ( | ) | const |
Row 3 Column 3 of orientation matrix equivalent to this quaternion.
double gams::pose::Quaternion::mag | ( | ) | const |
Returns the magnitude of this quaternion.
double gams::pose::Quaternion::mag_squared | ( | ) | const |
Returns the magnitude of this quaternion, squared.
Faster than squaring the return value of mag()
Quaternion& gams::pose::Quaternion::negate | ( | ) |
Flip the sign of all parts of the quaternion; equivalent to (but potentially faster than) this->scale(-1);.
Quaternion gams::pose::Quaternion::operator* | ( | const Quaternion & | rhs | ) | const |
Calculate hamilton product, this * rhs, and return new Quaternion.
rhs | right-hand-side to multiply with |
Quaternion& gams::pose::Quaternion::operator*= | ( | const Quaternion & | rhs | ) |
Calculate hamilton product, this * rhs, and store into this.
Equivalent to hamilton_product(*this, *this, rhs)
rhs | right-hand-side to multiply with |
|
constexpr |
Copy and conjugate this quaternion.
void gams::pose::Quaternion::orient_by | ( | Quaternion | rot | ) |
Treat this quaternion as a position quaternion (w should be zero), and orient it by the orientation represented by rot.
rot | the Quaternion angle to orient by |
Quaternion gams::pose::Quaternion::pow | ( | const Quaternion & | e | ) | const |
Calculate this quaternion raised to a quaternion power, return result in a new quaternion.
Quaternion gams::pose::Quaternion::pow | ( | double | e | ) | const |
Calculate this quaternion raised to a scalar power, return result in a new quaternion.
void gams::pose::Quaternion::pow_this | ( | const Quaternion & | e | ) |
Calculate this quaternion raised to a quaternion power, store result in this quaternion.
void gams::pose::Quaternion::pow_this | ( | double | e | ) |
Calculate this quaternion raised to a scalar power, store result in this quaternion.
|
inline |
Calculate hamilton product, lhs * this, and store into this.
Equivalent to hamilton_product(*this, lhs, *this)
lhs | left-hand-side to multiply with |
Definition at line 159 of file Quaternion.h.
void gams::pose::Quaternion::scale | ( | double | s | ) |
Multiply each part of this quaternion by s.
Quaternion gams::pose::Quaternion::slerp | ( | const Quaternion & | o, |
double | t | ||
) |
If *this and o are unit quaternions, interpolate a quaternion that is partially between them, and return it as a new quaternion.
If either quaternion is not a unit quaternion, the calculation will not produce an error, but will be meaningless.
o | the other unit quaternion |
t | how "close" to this quaternion the result should be, in a range from 0 to 1, inclusive, where 0 is *this, 1 is o, and 0.5 is halfway inbetween. |
void gams::pose::Quaternion::slerp_this | ( | const Quaternion & | o, |
double | t | ||
) |
If *this and o are unit quaternions, interpolate a quaternion that is partially between them, and store it in *this.
If either quaternion is not a unit quaternion, the calculation will not produce an error, but will be meaningless.
o | the other unit quaternion |
t | how "close" to this quaternion the result should be, in a range from 0 to 1, inclusive, where 0 is *this, 1 is o, and 0.5 is halfway inbetween. |
void gams::pose::Quaternion::to_angular_vector | ( | double & | rx, |
double & | ry, | ||
double & | rz | ||
) | const |
void gams::pose::Quaternion::to_angular_vector | ( | OrientationVector & | rot | ) | const |
void gams::pose::Quaternion::to_linear_vector | ( | double & | x, |
double & | y, | ||
double & | z | ||
) | const |
void gams::pose::Quaternion::to_linear_vector | ( | PositionVector & | loc | ) | const |
|
constexpr |
getter of w (or real scalar) part of quaternion
double gams::pose::Quaternion::w | ( | double | new_w | ) |
setter of w (or real scalar) part of quaternion
|
constexpr |
getter of x (or i) part of quaternion
double gams::pose::Quaternion::x | ( | double | new_x | ) |
getter of x (or i) part of quaternion
|
constexpr |
getter of y (or j) part of quaternion
double gams::pose::Quaternion::y | ( | double | new_y | ) |
getter of y (or j) part of quaternion
|
constexpr |
getter of z (or k) part of quaternion
double gams::pose::Quaternion::z | ( | double | new_z | ) |
getter of z (or k) part of quaternion
|
private |
Definition at line 394 of file Quaternion.h.
|
private |
Definition at line 394 of file Quaternion.h.
|
private |
Definition at line 394 of file Quaternion.h.
|
private |
Definition at line 394 of file Quaternion.h.