The quaternion class used to represent 3D orientations and rotations. More...
#include <Quaternion.h>
Public Types | |
typedef AngleAxis< Scalar > | AngleAxisType |
typedef Matrix< Scalar, 4, 1 > | Coefficients |
typedef Matrix< Scalar, 3, 3 > | Matrix3 |
typedef _Scalar | Scalar |
typedef Matrix< Scalar, 3, 1 > | Vector3 |
Public Member Functions | |
Scalar | angularDistance (const Quaternion &other) const |
template<typename NewScalarType > | |
ei_cast_return_type < Quaternion, Quaternion < NewScalarType > >::type | cast () const |
Coefficients & | coeffs () |
const Coefficients & | coeffs () const |
Quaternion | conjugate (void) const |
Scalar | dot (const Quaternion &other) const |
Quaternion | inverse (void) const |
bool | isApprox (const Quaternion &other, typename NumTraits< Scalar >::Real prec=precision< Scalar >()) const |
Scalar | norm () const |
void | normalize () |
Quaternion | normalized () const |
template<typename Derived > | |
Vector3 | operator* (const MatrixBase< Derived > &vec) const |
Quaternion | operator* (const Quaternion &q) const |
Quaternion & | operator*= (const Quaternion &q) |
template<typename Derived > | |
Quaternion & | operator= (const MatrixBase< Derived > &m) |
Quaternion & | operator= (const AngleAxisType &aa) |
Quaternion & | operator= (const Quaternion &other) |
template<typename OtherScalarType > | |
Quaternion (const Quaternion< OtherScalarType > &other) | |
template<typename Derived > | |
Quaternion (const MatrixBase< Derived > &other) | |
Quaternion (const AngleAxisType &aa) | |
Quaternion (const Quaternion &other) | |
Quaternion (Scalar w, Scalar x, Scalar y, Scalar z) | |
Quaternion () | |
template<typename Derived1 , typename Derived2 > | |
Quaternion & | setFromTwoVectors (const MatrixBase< Derived1 > &a, const MatrixBase< Derived2 > &b) |
Quaternion & | setIdentity () |
Quaternion | slerp (Scalar t, const Quaternion &other) const |
Scalar | squaredNorm () const |
Matrix3 | toRotationMatrix (void) const |
Block< Coefficients, 3, 1 > | vec () |
const Block< Coefficients, 3, 1 > | vec () const |
Scalar & | w () |
Scalar | w () const |
Scalar & | x () |
Scalar | x () const |
Scalar & | y () |
Scalar | y () const |
Scalar & | z () |
Scalar | z () const |
Static Public Member Functions | |
static Quaternion | Identity () |
Protected Attributes | |
Coefficients | m_coeffs |
Private Types | |
typedef RotationBase < Quaternion< _Scalar >, 3 > | Base |
The quaternion class used to represent 3D orientations and rotations.
_Scalar | the scalar type, i.e., the type of the coefficients |
This class represents a quaternion that is a convenient representation of orientations and rotations of objects in three dimensions. Compared to other representations like Euler angles or 3x3 matrices, quatertions offer the following advantages:
The following two typedefs are provided for convenience:
Quaternionf
for float
Quaterniond
for double
Definition at line 61 of file Quaternion.h.
typedef AngleAxis<Scalar> Quaternion< _Scalar >::AngleAxisType |
the equivalent angle-axis type
Definition at line 80 of file Quaternion.h.
typedef RotationBase<Quaternion<_Scalar>,3> Quaternion< _Scalar >::Base [private] |
Definition at line 63 of file Quaternion.h.
typedef Matrix<Scalar, 4, 1> Quaternion< _Scalar >::Coefficients |
the type of the Coefficients 4-vector
Definition at line 74 of file Quaternion.h.
typedef Matrix<Scalar,3,3> Quaternion< _Scalar >::Matrix3 |
the equivalent rotation matrix type
Definition at line 78 of file Quaternion.h.
typedef _Scalar Quaternion< _Scalar >::Scalar |
the scalar type of the coefficients
Reimplemented from RotationBase< Quaternion< _Scalar >, 3 >.
Definition at line 71 of file Quaternion.h.
typedef Matrix<Scalar,3,1> Quaternion< _Scalar >::Vector3 |
the type of a 3D vector
Definition at line 76 of file Quaternion.h.
Quaternion< _Scalar >::Quaternion | ( | ) | [inline] |
Default constructor leaving the quaternion uninitialized.
Definition at line 113 of file Quaternion.h.
Quaternion< _Scalar >::Quaternion | ( | Scalar | w, | |
Scalar | x, | |||
Scalar | y, | |||
Scalar | z | |||
) | [inline] |
Constructs and initializes the quaternion from its four coefficients w, x, y and z.
x
, y
, z
, w
] Definition at line 122 of file Quaternion.h.
Quaternion< _Scalar >::Quaternion | ( | const Quaternion< _Scalar > & | other | ) | [inline] |
Copy constructor
Definition at line 126 of file Quaternion.h.
Quaternion< _Scalar >::Quaternion | ( | const AngleAxisType & | aa | ) | [inline, explicit] |
Constructs and initializes a quaternion from the angle-axis aa
Definition at line 129 of file Quaternion.h.
Quaternion< _Scalar >::Quaternion | ( | const MatrixBase< Derived > & | other | ) | [inline, explicit] |
Constructs and initializes a quaternion from either:
Definition at line 137 of file Quaternion.h.
Quaternion< _Scalar >::Quaternion | ( | const Quaternion< OtherScalarType > & | other | ) | [inline, explicit] |
Copy constructor with scalar type conversion
Definition at line 206 of file Quaternion.h.
Scalar Quaternion< Scalar >::angularDistance | ( | const Quaternion< _Scalar > & | other | ) | const [inline] |
Definition at line 439 of file Quaternion.h.
ei_cast_return_type<Quaternion,Quaternion<NewScalarType> >::type Quaternion< _Scalar >::cast | ( | ) | const [inline] |
*this
with scalar type casted to NewScalarType Note that if NewScalarType is equal to the current scalar type of *this
then this function smartly returns a const reference to *this
.
Definition at line 201 of file Quaternion.h.
Coefficients& Quaternion< _Scalar >::coeffs | ( | ) | [inline] |
Definition at line 110 of file Quaternion.h.
const Coefficients& Quaternion< _Scalar >::coeffs | ( | ) | const [inline] |
Definition at line 107 of file Quaternion.h.
Quaternion< Scalar > Quaternion< Scalar >::conjugate | ( | void | ) | const [inline] |
*this
which is equal to the multiplicative inverse if the quaternion is normalized. The conjugate of a quaternion represents the opposite rotation.Definition at line 430 of file Quaternion.h.
Scalar Quaternion< _Scalar >::dot | ( | const Quaternion< _Scalar > & | other | ) | const [inline] |
*this
and other Geometrically speaking, the dot product of two unit quaternions corresponds to the cosine of half the angle between the two rotations. Definition at line 175 of file Quaternion.h.
static Quaternion Quaternion< _Scalar >::Identity | ( | ) | [inline, static] |
Definition at line 147 of file Quaternion.h.
Quaternion< Scalar > Quaternion< Scalar >::inverse | ( | void | ) | const [inline] |
*this
Note that in most cases, i.e., if you simply want the opposite rotation, and/or the quaternion is normalized, then it is enough to use the conjugate.Reimplemented from RotationBase< Quaternion< _Scalar >, 3 >.
Definition at line 410 of file Quaternion.h.
bool Quaternion< _Scalar >::isApprox | ( | const Quaternion< _Scalar > & | other, | |
typename NumTraits< Scalar >::Real | prec = precision<Scalar>() | |||
) | const [inline] |
true
if *this
is approximately equal to other, within the precision determined by prec.Definition at line 213 of file Quaternion.h.
Scalar Quaternion< _Scalar >::norm | ( | ) | const [inline] |
Definition at line 161 of file Quaternion.h.
void Quaternion< _Scalar >::normalize | ( | void | ) | [inline] |
Normalizes the quaternion *this
Definition at line 165 of file Quaternion.h.
Quaternion Quaternion< _Scalar >::normalized | ( | ) | const [inline] |
*this
Definition at line 168 of file Quaternion.h.
Quaternion< Scalar >::Vector3 Quaternion< Scalar >::operator* | ( | const MatrixBase< Derived > & | v | ) | const [inline] |
Rotation of a vector by a quaternion.
Definition at line 285 of file Quaternion.h.
Quaternion< Scalar > Quaternion< Scalar >::operator* | ( | const Quaternion< _Scalar > & | other | ) | const [inline] |
Definition at line 263 of file Quaternion.h.
Quaternion< Scalar > & Quaternion< Scalar >::operator*= | ( | const Quaternion< _Scalar > & | other | ) | [inline] |
Definition at line 270 of file Quaternion.h.
Quaternion< Scalar > & Quaternion< Scalar >::operator= | ( | const MatrixBase< Derived > & | xpr | ) | [inline] |
Set *this
from the expression xpr:
Definition at line 322 of file Quaternion.h.
Quaternion< Scalar > & Quaternion< Scalar >::operator= | ( | const AngleAxisType & | aa | ) | [inline] |
Set *this
from an angle-axis aa and returns a reference to *this
Definition at line 307 of file Quaternion.h.
Quaternion< Scalar > & Quaternion< Scalar >::operator= | ( | const Quaternion< _Scalar > & | other | ) | [inline] |
Definition at line 298 of file Quaternion.h.
Quaternion< Scalar > & Quaternion< Scalar >::setFromTwoVectors | ( | const MatrixBase< Derived1 > & | a, | |
const MatrixBase< Derived2 > & | b | |||
) | [inline] |
Sets *this to be a quaternion representing a rotation sending the vector a to the vector b.
Note that the two input vectors do not have to be normalized.
Definition at line 373 of file Quaternion.h.
Quaternion& Quaternion< _Scalar >::setIdentity | ( | ) | [inline] |
Definition at line 151 of file Quaternion.h.
Quaternion< Scalar > Quaternion< Scalar >::slerp | ( | Scalar | t, | |
const Quaternion< _Scalar > & | other | |||
) | const [inline] |
*this
and other at the parameter t Definition at line 451 of file Quaternion.h.
Scalar Quaternion< _Scalar >::squaredNorm | ( | ) | const [inline] |
Definition at line 156 of file Quaternion.h.
Quaternion< Scalar >::Matrix3 Quaternion< Scalar >::toRotationMatrix | ( | void | ) | const [inline] |
Convert the quaternion to a 3x3 rotation matrix
Reimplemented from RotationBase< Quaternion< _Scalar >, 3 >.
Definition at line 331 of file Quaternion.h.
Block<Coefficients,3,1> Quaternion< _Scalar >::vec | ( | ) | [inline] |
Definition at line 104 of file Quaternion.h.
const Block<Coefficients,3,1> Quaternion< _Scalar >::vec | ( | ) | const [inline] |
Definition at line 101 of file Quaternion.h.
Scalar& Quaternion< _Scalar >::w | ( | ) | [inline] |
w
coefficient Definition at line 98 of file Quaternion.h.
Scalar Quaternion< _Scalar >::w | ( | ) | const [inline] |
w
coefficient Definition at line 89 of file Quaternion.h.
Scalar& Quaternion< _Scalar >::x | ( | ) | [inline] |
x
coefficient Definition at line 92 of file Quaternion.h.
Scalar Quaternion< _Scalar >::x | ( | ) | const [inline] |
x
coefficient Definition at line 83 of file Quaternion.h.
Scalar& Quaternion< _Scalar >::y | ( | ) | [inline] |
y
coefficient Definition at line 94 of file Quaternion.h.
Scalar Quaternion< _Scalar >::y | ( | ) | const [inline] |
y
coefficient Definition at line 85 of file Quaternion.h.
Scalar& Quaternion< _Scalar >::z | ( | ) | [inline] |
z
coefficient Definition at line 96 of file Quaternion.h.
Scalar Quaternion< _Scalar >::z | ( | ) | const [inline] |
z
coefficient Definition at line 87 of file Quaternion.h.
Coefficients Quaternion< _Scalar >::m_coeffs [protected] |
Definition at line 217 of file Quaternion.h.