The quaternion class used to represent 3D orientations and rotations. More...
#include <Quaternion.h>
Public Types | |
typedef _Scalar | Scalar |
typedef Matrix< Scalar, 4, 1 > | Coefficients |
typedef Matrix< Scalar, 3, 1 > | Vector3 |
typedef Matrix< Scalar, 3, 3 > | Matrix3 |
typedef AngleAxis< Scalar > | AngleAxisType |
typedef _Scalar | Scalar |
typedef internal::traits < Quaternion< Scalar, _Options > >::Coefficients | Coefficients |
typedef Base::AngleAxisType | AngleAxisType |
Public Member Functions | |
Scalar | x () const |
Scalar | y () const |
Scalar | z () const |
Scalar | w () const |
Scalar & | x () |
Scalar & | y () |
Scalar & | z () |
Scalar & | w () |
const Block< const Coefficients, 3, 1 > | vec () const |
Block< Coefficients, 3, 1 > | vec () |
const Coefficients & | coeffs () const |
Coefficients & | coeffs () |
Quaternion () | |
Quaternion (Scalar w, Scalar x, Scalar y, Scalar z) | |
Quaternion (const Quaternion &other) | |
Quaternion (const AngleAxisType &aa) | |
template<typename Derived > | |
Quaternion (const MatrixBase< Derived > &other) | |
Quaternion & | operator= (const Quaternion &other) |
Quaternion & | operator= (const AngleAxisType &aa) |
template<typename Derived > | |
Quaternion & | operator= (const MatrixBase< Derived > &m) |
Quaternion & | setIdentity () |
Scalar | squaredNorm () const |
Scalar | norm () const |
void | normalize () |
Quaternion | normalized () const |
Scalar | eigen2_dot (const Quaternion &other) const |
Scalar | angularDistance (const Quaternion &other) const |
Matrix3 | toRotationMatrix (void) const |
template<typename Derived1 , typename Derived2 > | |
Quaternion & | setFromTwoVectors (const MatrixBase< Derived1 > &a, const MatrixBase< Derived2 > &b) |
Quaternion | operator* (const Quaternion &q) const |
Quaternion & | operator*= (const Quaternion &q) |
Quaternion | inverse (void) const |
Quaternion | conjugate (void) const |
Quaternion | slerp (Scalar t, const Quaternion &other) const |
template<typename Derived > | |
Vector3 | operator* (const MatrixBase< Derived > &vec) const |
template<typename NewScalarType > | |
internal::cast_return_type < Quaternion, Quaternion < NewScalarType > >::type | cast () const |
template<typename OtherScalarType > | |
Quaternion (const Quaternion< OtherScalarType > &other) | |
bool | isApprox (const Quaternion &other, typename NumTraits< Scalar >::Real prec=precision< Scalar >()) const |
Quaternion () | |
Quaternion (Scalar w, Scalar x, Scalar y, Scalar z) | |
Quaternion (const Scalar *data) | |
template<class Derived > | |
EIGEN_STRONG_INLINE | Quaternion (const QuaternionBase< Derived > &other) |
Quaternion (const AngleAxisType &aa) | |
template<typename Derived > | |
Quaternion (const MatrixBase< Derived > &other) | |
Coefficients & | coeffs () |
const Coefficients & | coeffs () const |
Static Public Member Functions | |
static Quaternion | Identity () |
Static Protected Member Functions | |
static EIGEN_STRONG_INLINE void | _check_template_params () |
Protected Attributes | |
Coefficients | m_coeffs |
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
typedef AngleAxis<Scalar> Quaternion< _Scalar >::AngleAxisType |
the equivalent angle-axis type
typedef Base::AngleAxisType Quaternion< _Scalar >::AngleAxisType |
typedef Matrix<Scalar, 4, 1> Quaternion< _Scalar >::Coefficients |
the type of the Coefficients 4-vector
typedef internal::traits<Quaternion<Scalar,_Options> >::Coefficients Quaternion< _Scalar >::Coefficients |
typedef Matrix<Scalar,3,3> Quaternion< _Scalar >::Matrix3 |
the equivalent rotation matrix type
typedef _Scalar Quaternion< _Scalar >::Scalar |
the scalar type of the coefficients
Reimplemented from RotationBase< Quaternion< _Scalar >, 3 >.
typedef _Scalar Quaternion< _Scalar >::Scalar |
the scalar type of the coefficients
Reimplemented from RotationBase< Quaternion< _Scalar >, 3 >.
typedef Matrix<Scalar,3,1> Quaternion< _Scalar >::Vector3 |
the type of a 3D vector
Quaternion< _Scalar >::Quaternion | ( | ) | [inline] |
Default constructor leaving the quaternion uninitialized.
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
] Quaternion< _Scalar >::Quaternion | ( | const Quaternion< _Scalar > & | other | ) | [inline] |
Copy constructor
Quaternion< _Scalar >::Quaternion | ( | const AngleAxisType & | aa | ) | [inline, explicit] |
Constructs and initializes a quaternion from the angle-axis aa
Quaternion< _Scalar >::Quaternion | ( | const MatrixBase< Derived > & | other | ) | [inline, explicit] |
Constructs and initializes a quaternion from either:
Quaternion< _Scalar >::Quaternion | ( | const Quaternion< OtherScalarType > & | other | ) | [inline, explicit] |
Copy constructor with scalar type conversion
Quaternion< _Scalar >::Quaternion | ( | ) | [inline] |
Default constructor leaving the quaternion uninitialized.
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
] Quaternion< _Scalar >::Quaternion | ( | const Scalar * | data | ) | [inline] |
Constructs and initialize a quaternion from the array data
EIGEN_STRONG_INLINE Quaternion< _Scalar >::Quaternion | ( | const QuaternionBase< Derived > & | other | ) | [inline] |
Copy constructor
Quaternion< _Scalar >::Quaternion | ( | const AngleAxisType & | aa | ) | [inline, explicit] |
Constructs and initializes a quaternion from the angle-axis aa
Quaternion< _Scalar >::Quaternion | ( | const MatrixBase< Derived > & | other | ) | [inline, explicit] |
Constructs and initializes a quaternion from either:
static EIGEN_STRONG_INLINE void Quaternion< _Scalar >::_check_template_params | ( | ) | [inline, static, protected] |
Scalar Quaternion< Scalar >::angularDistance | ( | const Quaternion< _Scalar > & | other | ) | const [inline] |
internal::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
.
Coefficients& Quaternion< _Scalar >::coeffs | ( | ) | [inline] |
const Coefficients& Quaternion< _Scalar >::coeffs | ( | ) | const [inline] |
const Coefficients& Quaternion< _Scalar >::coeffs | ( | ) | const [inline] |
Coefficients& Quaternion< _Scalar >::coeffs | ( | ) | [inline] |
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.Scalar Quaternion< _Scalar >::eigen2_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. static Quaternion Quaternion< _Scalar >::Identity | ( | ) | [inline, static] |
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 >.
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.Scalar Quaternion< _Scalar >::norm | ( | ) | const [inline] |
void Quaternion< _Scalar >::normalize | ( | void | ) | [inline] |
Normalizes the quaternion *this
Quaternion Quaternion< _Scalar >::normalized | ( | ) | const [inline] |
*this
Quaternion< Scalar > Quaternion< Scalar >::operator* | ( | const Quaternion< _Scalar > & | other | ) | const [inline] |
Quaternion< Scalar >::Vector3 Quaternion< Scalar >::operator* | ( | const MatrixBase< Derived > & | v | ) | const [inline] |
Rotation of a vector by a quaternion.
Quaternion< Scalar > & Quaternion< Scalar >::operator*= | ( | const Quaternion< _Scalar > & | other | ) | [inline] |
Quaternion< Scalar > & Quaternion< Scalar >::operator= | ( | const AngleAxisType & | aa | ) | [inline] |
Set *this
from an angle-axis aa and returns a reference to *this
Quaternion< Scalar > & Quaternion< Scalar >::operator= | ( | const Quaternion< _Scalar > & | other | ) | [inline] |
Quaternion< Scalar > & Quaternion< Scalar >::operator= | ( | const MatrixBase< Derived > & | xpr | ) | [inline] |
Set *this
from the expression xpr:
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.
Quaternion& Quaternion< _Scalar >::setIdentity | ( | ) | [inline] |
Quaternion< Scalar > Quaternion< Scalar >::slerp | ( | Scalar | t, | |
const Quaternion< _Scalar > & | other | |||
) | const |
*this
and other at the parameter t Scalar Quaternion< _Scalar >::squaredNorm | ( | ) | const [inline] |
Quaternion< Scalar >::Matrix3 Quaternion< Scalar >::toRotationMatrix | ( | void | ) | const [inline] |
Convert the quaternion to a 3x3 rotation matrix
Reimplemented from RotationBase< Quaternion< _Scalar >, 3 >.
const Block<const Coefficients,3,1> Quaternion< _Scalar >::vec | ( | ) | const [inline] |
Block<Coefficients,3,1> Quaternion< _Scalar >::vec | ( | ) | [inline] |
Scalar Quaternion< _Scalar >::w | ( | ) | const [inline] |
w
coefficient Scalar& Quaternion< _Scalar >::w | ( | ) | [inline] |
w
coefficient Scalar Quaternion< _Scalar >::x | ( | ) | const [inline] |
x
coefficient Scalar& Quaternion< _Scalar >::x | ( | ) | [inline] |
x
coefficient Scalar Quaternion< _Scalar >::y | ( | ) | const [inline] |
y
coefficient Scalar& Quaternion< _Scalar >::y | ( | ) | [inline] |
y
coefficient Scalar& Quaternion< _Scalar >::z | ( | ) | [inline] |
z
coefficient Scalar Quaternion< _Scalar >::z | ( | ) | const [inline] |
z
coefficient Coefficients Quaternion< _Scalar >::m_coeffs [protected] |