A quaternion class. More...
#include <ignition/math/Quaternion.hh>
Public Member Functions | |
Quaternion () | |
Default Constructor. More... | |
Quaternion (const T &_w, const T &_x, const T &_y, const T &_z) | |
Constructor. More... | |
Quaternion (const T &_roll, const T &_pitch, const T &_yaw) | |
Constructor from Euler angles in radians. More... | |
Quaternion (const Vector3< T > &_axis, const T &_angle) | |
Constructor from axis angle. More... | |
Quaternion (const Vector3< T > &_rpy) | |
Constructor. More... | |
Quaternion (const Quaternion< T > &_qt) | |
Copy constructor. More... | |
~Quaternion () | |
Destructor. More... | |
void | Axis (T _ax, T _ay, T _az, T _aa) |
Set the quaternion from an axis and angle. More... | |
void | Axis (const Vector3< T > &_axis, T _a) |
Set the quaternion from an axis and angle. More... | |
void | Correct () |
Correct any nan. More... | |
T | Dot (const Quaternion< T > &_q) const |
Dot product. More... | |
void | Euler (const Vector3< T > &_vec) |
Set the quaternion from Euler angles. More... | |
void | Euler (T _roll, T _pitch, T _yaw) |
Set the quaternion from Euler angles. More... | |
Vector3< T > | Euler () const |
Return the rotation in Euler angles. More... | |
Quaternion< T > | Exp () const |
Return the exponent. More... | |
Quaternion< T > | Inverse () const |
Get the inverse of this quaternion. More... | |
void | Invert () |
Invert the quaternion. More... | |
bool | IsFinite () const |
See if a quatern is finite (e.g., not nan) More... | |
Quaternion< T > | Log () const |
Return the logarithm. More... | |
void | Normalize () |
Normalize the quaternion. More... | |
bool | operator!= (const Quaternion< T > &_qt) const |
Not equal to operator. More... | |
Quaternion< T > | operator* (const Quaternion< T > &_q) const |
Multiplication operator. More... | |
Quaternion< T > | operator* (const T &_f) const |
Multiplication operator. More... | |
Vector3< T > | operator* (const Vector3< T > &_v) const |
Vector3 multiplication operator. More... | |
Quaternion< T > | operator*= (const Quaternion< T > &qt) |
Multiplication operator. More... | |
Quaternion< T > | operator+ (const Quaternion< T > &_qt) const |
Addition operator. More... | |
Quaternion< T > | operator+= (const Quaternion< T > &_qt) |
Addition operator. More... | |
Quaternion< T > | operator- (const Quaternion< T > &_qt) const |
Substraction operator. More... | |
Quaternion< T > | operator- () const |
Unary minus operator. More... | |
Quaternion< T > | operator-= (const Quaternion< T > &_qt) |
Substraction operator. More... | |
Quaternion< T > & | operator= (const Quaternion< T > &_qt) |
Equal operator. More... | |
bool | operator== (const Quaternion< T > &_qt) const |
Equal to operator. More... | |
T | Pitch () const |
Get the Euler pitch angle in radians. More... | |
T | Roll () const |
Get the Euler roll angle in radians. More... | |
Vector3< T > | RotateVector (const Vector3< T > &_vec) const |
Rotate a vector using the quaternion. More... | |
Vector3< T > | RotateVectorReverse (Vector3< T > _vec) const |
Do the reverse rotation of a vector by this quaternion. More... | |
void | Round (int _precision) |
Round all values to _precision decimal places. More... | |
void | Scale (T _scale) |
Scale a Quaternion<T>ion. More... | |
void | Set (T _w, T _x, T _y, T _z) |
Set this quaternion from 4 floating numbers. More... | |
void | ToAxis (Vector3< T > &_axis, T &_angle) const |
Return rotation as axis and angle. More... | |
const T & | W () const |
Get the w component. More... | |
T & | W () |
Get a mutable w component. More... | |
void | W (T _v) |
Set the w component. More... | |
const T & | X () const |
Get the x component. More... | |
T & | X () |
Get a mutable x component. More... | |
void | X (T _v) |
Set the x component. More... | |
Vector3< T > | XAxis () const |
Return the X axis. More... | |
const T & | Y () const |
Get the y component. More... | |
T & | Y () |
Get a mutable y component. More... | |
void | Y (T _v) |
Set the y component. More... | |
T | Yaw () const |
Get the Euler yaw angle in radians. More... | |
Vector3< T > | YAxis () const |
Return the Y axis. More... | |
const T & | Z () const |
Get the z component. More... | |
T & | Z () |
Get a mutable z component. More... | |
void | Z (T _v) |
Set the z component. More... | |
Vector3< T > | ZAxis () const |
Return the Z axis. More... | |
Static Public Member Functions | |
static Quaternion< T > | EulerToQuaternion (const Vector3< T > &_vec) |
Convert euler angles to quatern. More... | |
static Quaternion< T > | EulerToQuaternion (T _x, T _y, T _z) |
Convert euler angles to quatern. More... | |
static Quaternion< T > | Slerp (T _fT, const Quaternion< T > &_rkP, const Quaternion< T > &_rkQ, bool _shortestPath=false) |
Spherical linear interpolation between 2 quaternions, given the ends and an interpolation parameter between 0 and 1. More... | |
static Quaternion< T > | Squad (T _fT, const Quaternion< T > &_rkP, const Quaternion< T > &_rkA, const Quaternion< T > &_rkB, const Quaternion< T > &_rkQ, bool _shortestPath=false) |
Spherical quadratic interpolation given the ends and an interpolation parameter between 0 and 1. More... | |
Static Public Attributes | |
static const Quaternion | Identity |
math::Quaternion(1, 0, 0, 1) More... | |
Friends | |
std::ostream & | operator<< (std::ostream &_out, const ignition::math::Quaternion< T > &_q) |
Stream insertion operator. More... | |
std::istream & | operator>> (std::istream &_in, ignition::math::Quaternion< T > &_q) |
Stream extraction operator. More... | |
A quaternion class.
|
inline |
Default Constructor.
|
inline |
Constructor.
[in] | _w | W param |
[in] | _x | X param |
[in] | _y | Y param |
[in] | _z | Z param |
|
inline |
Constructor from Euler angles in radians.
[in] | _roll | roll |
[in] | _pitch | pitch |
[in] | _yaw | yaw |
References ignition::math::Quaternion< T >::Euler().
|
inline |
Constructor from axis angle.
[in] | _axis | the rotation axis |
[in] | _angle | the rotation angle in radians |
References ignition::math::Quaternion< T >::Axis().
|
inline |
|
inline |
Copy constructor.
qt | Quaternion<T> to copy |
|
inline |
Destructor.
|
inline |
Set the quaternion from an axis and angle.
[in] | _x | X axis |
[in] | _y | Y axis |
[in] | _z | Z axis |
[in] | _a | Angle in radians |
References ignition::math::Quaternion< T >::Normalize().
Referenced by ignition::math::Quaternion< T >::Axis(), ignition::math::Quaternion< T >::Quaternion(), and ignition::math::Quaternion< T >::Scale().
|
inline |
Set the quaternion from an axis and angle.
[in] | _axis | Axis |
[in] | _a | Angle in radians |
References ignition::math::Quaternion< T >::Axis(), ignition::math::Vector3< T >::X(), ignition::math::Vector3< T >::Y(), and ignition::math::Vector3< T >::Z().
|
inline |
Correct any nan.
References ignition::math::equal().
|
inline |
Dot product.
[in] | _q | the other quaternion |
Referenced by ignition::math::Quaternion< T >::Slerp().
|
inline |
Set the quaternion from Euler angles.
The order of operations are roll, pitch, yaw.
[in] | vec | Euler angle |
References ignition::math::Quaternion< T >::Euler(), ignition::math::Vector3< T >::X(), ignition::math::Vector3< T >::Y(), and ignition::math::Vector3< T >::Z().
Referenced by ignition::math::Quaternion< T >::EulerToQuaternion().
|
inline |
Set the quaternion from Euler angles.
[in] | _roll | Roll angle (radians). |
[in] | _pitch | Roll angle (radians). |
[in] | _yaw | Roll angle (radians). |
References ignition::math::Quaternion< T >::Normalize().
|
inline |
Return the rotation in Euler angles.
References IGN_PI, ignition::math::Quaternion< T >::Normalize(), ignition::math::Vector3< T >::X(), ignition::math::Vector3< T >::Y(), and ignition::math::Vector3< T >::Z().
Referenced by ignition::math::Quaternion< T >::Euler(), ignition::math::Quaternion< T >::Pitch(), ignition::math::Quaternion< T >::Quaternion(), ignition::math::Quaternion< T >::Roll(), and ignition::math::Quaternion< T >::Yaw().
|
inlinestatic |
Convert euler angles to quatern.
[in] |
References ignition::math::Quaternion< T >::Euler().
Referenced by ignition::math::Quaternion< T >::EulerToQuaternion().
|
inlinestatic |
Convert euler angles to quatern.
[in] | _x | rotation along x |
[in] | _y | rotation along y |
[in] | _z | rotation along z |
References ignition::math::Quaternion< T >::EulerToQuaternion().
|
inline |
Return the exponent.
|
inline |
Get the inverse of this quaternion.
Referenced by ignition::math::Pose3< T >::CoordRotationSub(), ignition::math::Quaternion< T >::RotateVector(), and ignition::math::Quaternion< T >::RotateVectorReverse().
|
inline |
Invert the quaternion.
References ignition::math::Quaternion< T >::Normalize().
|
inline |
See if a quatern is finite (e.g., not nan)
|
inline |
Return the logarithm.
|
inline |
Normalize the quaternion.
Referenced by ignition::math::Quaternion< T >::Axis(), ignition::math::Pose3< T >::CoordRotationSub(), ignition::math::Quaternion< T >::Euler(), ignition::math::Quaternion< T >::Invert(), ignition::math::Matrix3< T >::Matrix3(), ignition::math::Matrix4< double >::Matrix4(), and ignition::math::Quaternion< T >::Slerp().
|
inline |
Not equal to operator.
[in] | _qt | Quaternion<T> for comparison |
References ignition::math::equal().
|
inline |
Multiplication operator.
[in] | _qt | Quaternion<T> for multiplication |
|
inline |
Multiplication operator.
[in] | _f | factor |
|
inline |
Vector3 multiplication operator.
[in] | _v | vector to multiply |
References ignition::math::Vector3< T >::Cross().
|
inline |
Multiplication operator.
[in] | _qt | Quaternion<T> for multiplication |
|
inline |
Addition operator.
[in] | _qt | quaternion for addition |
|
inline |
Addition operator.
[in] | _qt | quaternion for addition |
|
inline |
Substraction operator.
[in] | _qt | quaternion to substract |
|
inline |
Unary minus operator.
|
inline |
Substraction operator.
[in] | _qt | Quaternion<T> for substraction |
|
inline |
Equal operator.
[in] | _qt | Quaternion<T> to copy |
|
inline |
Equal to operator.
[in] | _qt | Quaternion<T> for comparison |
References ignition::math::equal().
|
inline |
Get the Euler pitch angle in radians.
References ignition::math::Quaternion< T >::Euler().
|
inline |
Get the Euler roll angle in radians.
References ignition::math::Quaternion< T >::Euler().
|
inline |
Rotate a vector using the quaternion.
[in] | _vec | vector to rotate |
References ignition::math::Quaternion< T >::Inverse(), ignition::math::Vector3< T >::X(), ignition::math::Vector3< T >::Y(), and ignition::math::Vector3< T >::Z().
|
inline |
Do the reverse rotation of a vector by this quaternion.
[in] | _vec | the vector |
References ignition::math::Quaternion< T >::Inverse(), ignition::math::Vector3< T >::X(), ignition::math::Vector3< T >::Y(), and ignition::math::Vector3< T >::Z().
|
inline |
Round all values to _precision decimal places.
[in] | _precision | the precision |
References ignition::math::precision().
|
inline |
Scale a Quaternion<T>ion.
[in] | _scale | Amount to scale this rotation |
References ignition::math::Quaternion< T >::Axis(), ignition::math::Quaternion< T >::ToAxis(), ignition::math::Vector3< T >::X(), ignition::math::Vector3< T >::Y(), and ignition::math::Vector3< T >::Z().
|
inline |
Set this quaternion from 4 floating numbers.
[in] | _u | u |
[in] | _x | x |
[in] | _y | y |
[in] | _z | z |
|
inlinestatic |
Spherical linear interpolation between 2 quaternions, given the ends and an interpolation parameter between 0 and 1.
[in] | _ft | the interpolation parameter |
[in] | _rkP | the beginning quaternion |
[in] | _rkQ | the end quaternion |
[in] | _shortestPath | when true, the rotation may be inverted to get to minimize rotation |
References ignition::math::Quaternion< T >::Dot(), and ignition::math::Quaternion< T >::Normalize().
Referenced by ignition::math::OnePoleQuaternion::Process(), and ignition::math::Quaternion< T >::Squad().
|
inlinestatic |
Spherical quadratic interpolation given the ends and an interpolation parameter between 0 and 1.
[in] | _ft | the interpolation parameter |
[in] | _rkP | the beginning quaternion |
[in] | _rkA | first intermediate quaternion |
[in] | _rkB | second intermediate quaternion |
[in] | _rkQ | the end quaternion |
[in] | _shortestPath | when true, the rotation may be inverted to get to minimize rotation |
References ignition::math::Quaternion< T >::Slerp().
|
inline |
Return rotation as axis and angle.
[in] | _axis | rotation axis |
[in] | _angle | ccw angle in radians |
References ignition::math::Vector3< T >::Set().
Referenced by ignition::math::Quaternion< T >::Scale().
|
inline |
Get the w component.
Referenced by ignition::math::Matrix3< T >::Matrix3(), ignition::math::Matrix4< double >::Matrix4(), ignition::math::Pose3< T >::RotatePositionAboutOrigin(), and ignition::math::Matrix4< double >::Rotation().
|
inline |
Get a mutable w component.
|
inline |
Set the w component.
[in] | _v | The new value for the w quaternion component. |
|
inline |
Get the x component.
Referenced by ignition::math::Pose3< T >::CoordPoseSolve(), ignition::math::Pose3< T >::CoordPositionAdd(), ignition::math::Pose3< T >::CoordPositionSub(), ignition::math::Matrix3< T >::Matrix3(), ignition::math::Matrix4< double >::Matrix4(), ignition::math::Pose3< T >::RotatePositionAboutOrigin(), and ignition::math::Matrix4< double >::Rotation().
|
inline |
Get a mutable x component.
|
inline |
Set the x component.
[in] | _v | The new value for the x quaternion component. |
|
inline |
Return the X axis.
|
inline |
Get the y component.
Referenced by ignition::math::Pose3< T >::CoordPoseSolve(), ignition::math::Pose3< T >::CoordPositionAdd(), ignition::math::Pose3< T >::CoordPositionSub(), ignition::math::Matrix3< T >::Matrix3(), ignition::math::Matrix4< double >::Matrix4(), ignition::math::Pose3< T >::RotatePositionAboutOrigin(), and ignition::math::Matrix4< double >::Rotation().
|
inline |
Get a mutable y component.
|
inline |
Set the y component.
[in] | _v | The new value for the y quaternion component. |
|
inline |
Get the Euler yaw angle in radians.
References ignition::math::Quaternion< T >::Euler().
|
inline |
Return the Y axis.
|
inline |
Get the z component.
Referenced by ignition::math::Pose3< T >::CoordPoseSolve(), ignition::math::Pose3< T >::CoordPositionAdd(), ignition::math::Pose3< T >::CoordPositionSub(), ignition::math::Matrix3< T >::Matrix3(), ignition::math::Matrix4< double >::Matrix4(), ignition::math::Pose3< T >::RotatePositionAboutOrigin(), and ignition::math::Matrix4< double >::Rotation().
|
inline |
Get a mutable z component.
|
inline |
Set the z component.
[in] | _v | The new value for the z quaternion component. |
|
inline |
Return the Z axis.
|
friend |
Stream insertion operator.
[in] | _out | output stream |
[in] | _q | quaternion to output |
|
friend |
Stream extraction operator.
[in] | _in | input stream |
[in] | _q | Quaternion<T> to read values into |
|
static |
math::Quaternion(1, 0, 0, 1)
Referenced by ignition::math::Pose3< T >::Reset().