GAMS  1.4.0
gams::pose::Quaternion Class Reference

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...
 
Quaternionconjugate ()
 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...
 
Quaternionnegate ()
 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...
 
Quaternionoperator*= (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_
 

Detailed Description

Used internally to implement angle operations.

Not reference-frame aware.

Definition at line 74 of file Quaternion.h.

Constructor & Destructor Documentation

◆ Quaternion() [1/5]

constexpr gams::pose::Quaternion::Quaternion ( )
inlineconstexpr

Default constructor.

Initializes x, y, z, and w to zero.

Definition at line 80 of file Quaternion.h.

◆ Quaternion() [2/5]

constexpr gams::pose::Quaternion::Quaternion ( double  x,
double  y,
double  z,
double  w 
)
constexpr

Primary constructor.

Specifies each term explicitly

◆ Quaternion() [3/5]

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.

◆ Quaternion() [4/5]

gams::pose::Quaternion::Quaternion ( const OrientationVector rot)
explicit

Constructor which converts a orientation vector into the corresponding quaternion representation.

See OrientationVector for details of the orientation vector representation.

◆ Quaternion() [5/5]

gams::pose::Quaternion::Quaternion ( const PositionVector loc)
explicit

Constructor which converts a position vector into the corresponding quaternion representation; x, y, and z are copied over.

The w term is 0

Member Function Documentation

◆ angle_to()

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.

Parameters
targetthe target Quaternion
Returns
the angle in radians between this and the target

◆ conjugate()

Quaternion& gams::pose::Quaternion::conjugate ( )

Conjugate this quaternion in-place; may use in place of invert for unit quaternions for better performance.

Returns
*this, after conjugation

◆ dot_product()

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.

Parameters
rhsthe Quaternion to dot-multiply with
Returns
the scalar result.

◆ exp()

Quaternion gams::pose::Quaternion::exp ( ) const

Calculate e to the power of this quaternion, return result as new quaternion.

Returns
result

◆ exp_this()

void gams::pose::Quaternion::exp_this ( )

Calculate e to the power of this quaternion, store result in this quaternion.

◆ from_angular_vector() [1/2]

void gams::pose::Quaternion::from_angular_vector ( const OrientationVector rot)

◆ from_angular_vector() [2/2]

void gams::pose::Quaternion::from_angular_vector ( double  rx,
double  ry,
double  rz 
)

◆ from_linear_vector() [1/2]

void gams::pose::Quaternion::from_linear_vector ( const PositionVector loc)

◆ from_linear_vector() [2/2]

void gams::pose::Quaternion::from_linear_vector ( double  x,
double  y,
double  z 
)

◆ hamilton_product()

static void gams::pose::Quaternion::hamilton_product ( Quaternion into,
const Quaternion lhs,
const Quaternion rhs 
)
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)

Parameters
intodestination quaternion; will be overwritten
lhsleft-hand-side source quaternion (non-commutative)
rhsright-hand-side source quaternion (non-commutative)

◆ imag()

double gams::pose::Quaternion::imag ( ) const

Returns the magnitude of imaginary part of this quaternion.

◆ inner_product()

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.

Parameters
rhsthe Quaternion to multiply with
Returns
the scalar result.

◆ invert()

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.

◆ ln()

Quaternion gams::pose::Quaternion::ln ( ) const

Calculate the natural log of this quaternion, return result in a new quaternion.

Returns
result

◆ ln_this()

void gams::pose::Quaternion::ln_this ( )

Calculate natural log of this quaternion, store result in this quaternion.

◆ m11()

double gams::pose::Quaternion::m11 ( ) const

Row 1 Column 1 of orientation matrix equivalent to this quaternion.

◆ m12()

double gams::pose::Quaternion::m12 ( ) const

Row 1 Column 2 of orientation matrix equivalent to this quaternion.

◆ m13()

double gams::pose::Quaternion::m13 ( ) const

Row 1 Column 3 of orientation matrix equivalent to this quaternion.

◆ m21()

double gams::pose::Quaternion::m21 ( ) const

Row 2 Column 1 of orientation matrix equivalent to this quaternion.

◆ m22()

double gams::pose::Quaternion::m22 ( ) const

Row 2 Column 2 of orientation matrix equivalent to this quaternion.

◆ m23()

double gams::pose::Quaternion::m23 ( ) const

Row 2 Column 3 of orientation matrix equivalent to this quaternion.

◆ m31()

double gams::pose::Quaternion::m31 ( ) const

Row 3 Column 1 of orientation matrix equivalent to this quaternion.

◆ m32()

double gams::pose::Quaternion::m32 ( ) const

Row 3 Column 2 of orientation matrix equivalent to this quaternion.

◆ m33()

double gams::pose::Quaternion::m33 ( ) const

Row 3 Column 3 of orientation matrix equivalent to this quaternion.

◆ mag()

double gams::pose::Quaternion::mag ( ) const

Returns the magnitude of this quaternion.

◆ mag_squared()

double gams::pose::Quaternion::mag_squared ( ) const

Returns the magnitude of this quaternion, squared.

Faster than squaring the return value of mag()

◆ negate()

Quaternion& gams::pose::Quaternion::negate ( )

Flip the sign of all parts of the quaternion; equivalent to (but potentially faster than) this->scale(-1);.

Returns
*this, after negation

◆ operator*()

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

Calculate hamilton product, this * rhs, and return new Quaternion.

Parameters
rhsright-hand-side to multiply with
Returns
a new Quaternion object holding the result

◆ operator*=()

Quaternion& gams::pose::Quaternion::operator*= ( const Quaternion rhs)

Calculate hamilton product, this * rhs, and store into this.

Equivalent to hamilton_product(*this, *this, rhs)

Parameters
rhsright-hand-side to multiply with
Returns
*this, the result

◆ operator-()

constexpr Quaternion gams::pose::Quaternion::operator- ( ) const
constexpr

Copy and conjugate this quaternion.

Returns
a new Quaternion, holding the conjugation of this

◆ orient_by()

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.

Parameters
rotthe Quaternion angle to orient by

◆ pow() [1/2]

Quaternion gams::pose::Quaternion::pow ( const Quaternion e) const

Calculate this quaternion raised to a quaternion power, return result in a new quaternion.

Returns
result.

◆ pow() [2/2]

Quaternion gams::pose::Quaternion::pow ( double  e) const

Calculate this quaternion raised to a scalar power, return result in a new quaternion.

Returns
result.

◆ pow_this() [1/2]

void gams::pose::Quaternion::pow_this ( const Quaternion e)

Calculate this quaternion raised to a quaternion power, store result in this quaternion.

◆ pow_this() [2/2]

void gams::pose::Quaternion::pow_this ( double  e)

Calculate this quaternion raised to a scalar power, store result in this quaternion.

◆ pre_multiply()

void gams::pose::Quaternion::pre_multiply ( const Quaternion lhs)
inline

Calculate hamilton product, lhs * this, and store into this.

Equivalent to hamilton_product(*this, lhs, *this)

Parameters
lhsleft-hand-side to multiply with

Definition at line 159 of file Quaternion.h.

◆ scale()

void gams::pose::Quaternion::scale ( double  s)

Multiply each part of this quaternion by s.

◆ slerp()

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.

Parameters
othe other unit quaternion
thow "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.
Returns
the resulting interpolated quaternion

◆ slerp_this()

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.

Parameters
othe other unit quaternion
thow "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.

◆ to_angular_vector() [1/2]

void gams::pose::Quaternion::to_angular_vector ( double &  rx,
double &  ry,
double &  rz 
) const

◆ to_angular_vector() [2/2]

void gams::pose::Quaternion::to_angular_vector ( OrientationVector rot) const

◆ to_linear_vector() [1/2]

void gams::pose::Quaternion::to_linear_vector ( double &  x,
double &  y,
double &  z 
) const

◆ to_linear_vector() [2/2]

void gams::pose::Quaternion::to_linear_vector ( PositionVector loc) const

◆ w() [1/2]

constexpr double gams::pose::Quaternion::w ( ) const
constexpr

getter of w (or real scalar) part of quaternion

◆ w() [2/2]

double gams::pose::Quaternion::w ( double  new_w)

setter of w (or real scalar) part of quaternion

◆ x() [1/2]

constexpr double gams::pose::Quaternion::x ( ) const
constexpr

getter of x (or i) part of quaternion

◆ x() [2/2]

double gams::pose::Quaternion::x ( double  new_x)

getter of x (or i) part of quaternion

◆ y() [1/2]

constexpr double gams::pose::Quaternion::y ( ) const
constexpr

getter of y (or j) part of quaternion

◆ y() [2/2]

double gams::pose::Quaternion::y ( double  new_y)

getter of y (or j) part of quaternion

◆ z() [1/2]

constexpr double gams::pose::Quaternion::z ( ) const
constexpr

getter of z (or k) part of quaternion

◆ z() [2/2]

double gams::pose::Quaternion::z ( double  new_z)

getter of z (or k) part of quaternion

Member Data Documentation

◆ w_

double gams::pose::Quaternion::w_
private

Definition at line 394 of file Quaternion.h.

◆ x_

double gams::pose::Quaternion::x_
private

Definition at line 394 of file Quaternion.h.

◆ y_

double gams::pose::Quaternion::y_
private

Definition at line 394 of file Quaternion.h.

◆ z_

double gams::pose::Quaternion::z_
private

Definition at line 394 of file Quaternion.h.


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