Public Types | Public Member Functions | Static Public Member Functions | Static Protected Member Functions | Protected Attributes | Private Types
Quaternion< _Scalar > Class Template Reference

The quaternion class used to represent 3D orientations and rotations. More...

#include <Quaternion.h>

Inheritance diagram for Quaternion< _Scalar >:
Inheritance graph
[legend]

List of all members.

Public Types

typedef AngleAxis< ScalarAngleAxisType
typedef Base::AngleAxisType AngleAxisType
typedef Matrix< Scalar, 4, 1 > Coefficients
typedef internal::traits
< Quaternion< Scalar, _Options >
>::Coefficients 
Coefficients
typedef Matrix< Scalar, 3, 3 > Matrix3
typedef _Scalar Scalar
typedef _Scalar Scalar
typedef Matrix< Scalar, 3, 1 > Vector3

Public Member Functions

Scalar angularDistance (const Quaternion &other) const
template<typename NewScalarType >
internal::cast_return_type
< Quaternion, Quaternion
< NewScalarType > >::type 
cast () const
const Coefficientscoeffs () const
Coefficientscoeffs ()
Coefficientscoeffs ()
const Coefficientscoeffs () const
Quaternion conjugate (void) const
Scalar eigen2_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
Quaternion operator* (const Quaternion &q) const
template<typename Derived >
Vector3 operator* (const MatrixBase< Derived > &vec) const
Quaternionoperator*= (const Quaternion &q)
Quaternionoperator= (const Quaternion &other)
Quaternionoperator= (const AngleAxisType &aa)
template<typename Derived >
Quaternionoperator= (const MatrixBase< Derived > &m)
 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)
template<typename OtherScalarType >
 Quaternion (const Quaternion< OtherScalarType > &other)
 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)
template<typename Derived1 , typename Derived2 >
QuaternionsetFromTwoVectors (const MatrixBase< Derived1 > &a, const MatrixBase< Derived2 > &b)
QuaternionsetIdentity ()
Quaternion slerp (Scalar t, const Quaternion &other) const
Scalar squaredNorm () const
Matrix3 toRotationMatrix (void) const
const Block< const
Coefficients, 3, 1 > 
vec () const
Block< Coefficients, 3, 1 > vec ()
Scalar w () const
Scalarw ()
Scalar x () const
Scalarx ()
Scalar y () const
Scalary ()
Scalar z () const
Scalarz ()

Static Public Member Functions

static Quaternion Identity ()

Static Protected Member Functions

static EIGEN_STRONG_INLINE void _check_template_params ()

Protected Attributes

Coefficients m_coeffs

Private Types

typedef RotationBase
< Quaternion< _Scalar >, 3 > 
Base
typedef QuaternionBase
< Quaternion< _Scalar,
_Options > > 
Base

Detailed Description

template<typename _Scalar>
class Quaternion< _Scalar >

The quaternion class used to represent 3D orientations and rotations.

Parameters:
_Scalarthe scalar type, i.e., the type of the coefficients

This class represents a quaternion $ w+xi+yj+zk $ 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:

See also:
class AngleAxis, class Transform

Definition at line 60 of file Eigen2Support/Geometry/Quaternion.h.


Member Typedef Documentation

template<typename _Scalar>
typedef AngleAxis<Scalar> Quaternion< _Scalar >::AngleAxisType

the equivalent angle-axis type

Reimplemented from QuaternionBase< Quaternion< _Scalar, _Options > >.

Definition at line 79 of file Eigen2Support/Geometry/Quaternion.h.

template<typename _Scalar>
typedef Base::AngleAxisType Quaternion< _Scalar >::AngleAxisType

the equivalent angle-axis type

Reimplemented from QuaternionBase< Quaternion< _Scalar, _Options > >.

Definition at line 244 of file Geometry/Quaternion.h.

template<typename _Scalar>
typedef RotationBase<Quaternion<_Scalar>,3> Quaternion< _Scalar >::Base [private]
template<typename _Scalar>
typedef QuaternionBase<Quaternion<_Scalar,_Options> > Quaternion< _Scalar >::Base [private]

Reimplemented from QuaternionBase< Quaternion< _Scalar, _Options > >.

Definition at line 236 of file Geometry/Quaternion.h.

template<typename _Scalar>
typedef Matrix<Scalar, 4, 1> Quaternion< _Scalar >::Coefficients

the type of the Coefficients 4-vector

Reimplemented from QuaternionBase< Quaternion< _Scalar, _Options > >.

Definition at line 73 of file Eigen2Support/Geometry/Quaternion.h.

template<typename _Scalar>
typedef internal::traits<Quaternion<Scalar,_Options> >::Coefficients Quaternion< _Scalar >::Coefficients

Reimplemented from QuaternionBase< Quaternion< _Scalar, _Options > >.

Definition at line 243 of file Geometry/Quaternion.h.

template<typename _Scalar>
typedef Matrix<Scalar,3,3> Quaternion< _Scalar >::Matrix3

the equivalent rotation matrix type

Reimplemented from QuaternionBase< Quaternion< _Scalar, _Options > >.

Definition at line 77 of file Eigen2Support/Geometry/Quaternion.h.

template<typename _Scalar>
typedef _Scalar Quaternion< _Scalar >::Scalar

the scalar type of the coefficients

Reimplemented from RotationBase< Quaternion< _Scalar >, 3 >.

Definition at line 70 of file Eigen2Support/Geometry/Quaternion.h.

template<typename _Scalar>
typedef _Scalar Quaternion< _Scalar >::Scalar

the scalar type of the coefficients

Reimplemented from RotationBase< Quaternion< _Scalar >, 3 >.

Definition at line 238 of file Geometry/Quaternion.h.

template<typename _Scalar>
typedef Matrix<Scalar,3,1> Quaternion< _Scalar >::Vector3

the type of a 3D vector

Reimplemented from QuaternionBase< Quaternion< _Scalar, _Options > >.

Definition at line 75 of file Eigen2Support/Geometry/Quaternion.h.


Constructor & Destructor Documentation

template<typename _Scalar>
Quaternion< _Scalar >::Quaternion ( ) [inline]

Default constructor leaving the quaternion uninitialized.

Definition at line 112 of file Eigen2Support/Geometry/Quaternion.h.

template<typename _Scalar>
Quaternion< _Scalar >::Quaternion ( Scalar  w,
Scalar  x,
Scalar  y,
Scalar  z 
) [inline]

Constructs and initializes the quaternion $ w+xi+yj+zk $ from its four coefficients w, x, y and z.

Warning:
Note the order of the arguments: the real w coefficient first, while internally the coefficients are stored in the following order: [x, y, z, w]

Definition at line 121 of file Eigen2Support/Geometry/Quaternion.h.

template<typename _Scalar>
Quaternion< _Scalar >::Quaternion ( const Quaternion< _Scalar > &  other) [inline]

Copy constructor

Definition at line 125 of file Eigen2Support/Geometry/Quaternion.h.

template<typename _Scalar>
Quaternion< _Scalar >::Quaternion ( const AngleAxisType aa) [inline, explicit]

Constructs and initializes a quaternion from the angle-axis aa

Definition at line 128 of file Eigen2Support/Geometry/Quaternion.h.

template<typename _Scalar>
template<typename Derived >
Quaternion< _Scalar >::Quaternion ( const MatrixBase< Derived > &  other) [inline, explicit]

Constructs and initializes a quaternion from either:

  • a rotation matrix expression,
  • a 4D vector expression representing quaternion coefficients.
    See also:
    operator=(MatrixBase<Derived>)

Definition at line 136 of file Eigen2Support/Geometry/Quaternion.h.

template<typename _Scalar>
template<typename OtherScalarType >
Quaternion< _Scalar >::Quaternion ( const Quaternion< OtherScalarType > &  other) [inline, explicit]

Copy constructor with scalar type conversion

Definition at line 205 of file Eigen2Support/Geometry/Quaternion.h.

template<typename _Scalar>
Quaternion< _Scalar >::Quaternion ( ) [inline]

Default constructor leaving the quaternion uninitialized.

Definition at line 247 of file Geometry/Quaternion.h.

template<typename _Scalar>
Quaternion< _Scalar >::Quaternion ( Scalar  w,
Scalar  x,
Scalar  y,
Scalar  z 
) [inline]

Constructs and initializes the quaternion $ w+xi+yj+zk $ from its four coefficients w, x, y and z.

Warning:
Note the order of the arguments: the real w coefficient first, while internally the coefficients are stored in the following order: [x, y, z, w]

Definition at line 256 of file Geometry/Quaternion.h.

template<typename _Scalar>
Quaternion< _Scalar >::Quaternion ( const Scalar data) [inline]

Constructs and initialize a quaternion from the array data

Definition at line 259 of file Geometry/Quaternion.h.

template<typename _Scalar>
template<class Derived >
EIGEN_STRONG_INLINE Quaternion< _Scalar >::Quaternion ( const QuaternionBase< Derived > &  other) [inline]

Copy constructor

Definition at line 262 of file Geometry/Quaternion.h.

template<typename _Scalar>
Quaternion< _Scalar >::Quaternion ( const AngleAxisType aa) [inline, explicit]

Constructs and initializes a quaternion from the angle-axis aa

Definition at line 265 of file Geometry/Quaternion.h.

template<typename _Scalar>
template<typename Derived >
Quaternion< _Scalar >::Quaternion ( const MatrixBase< Derived > &  other) [inline, explicit]

Constructs and initializes a quaternion from either:

  • a rotation matrix expression,
  • a 4D vector expression representing quaternion coefficients.

Definition at line 272 of file Geometry/Quaternion.h.


Member Function Documentation

template<typename _Scalar>
static EIGEN_STRONG_INLINE void Quaternion< _Scalar >::_check_template_params ( ) [inline, static, protected]

Definition at line 281 of file Geometry/Quaternion.h.

template<typename Scalar >
Scalar Quaternion< Scalar >::angularDistance ( const Quaternion< _Scalar > &  other) const [inline]
Returns:
the angle (in radian) between two rotations
See also:
eigen2_dot()

Definition at line 417 of file Eigen2Support/Geometry/Quaternion.h.

template<typename _Scalar>
template<typename NewScalarType >
internal::cast_return_type<Quaternion,Quaternion<NewScalarType> >::type Quaternion< _Scalar >::cast ( ) const [inline]
Returns:
*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.

Reimplemented from QuaternionBase< Quaternion< _Scalar, _Options > >.

Definition at line 200 of file Eigen2Support/Geometry/Quaternion.h.

template<typename _Scalar>
const Coefficients& Quaternion< _Scalar >::coeffs ( ) const [inline]
Returns:
a read-only vector expression of the coefficients (x,y,z,w)

Reimplemented from QuaternionBase< Quaternion< _Scalar, _Options > >.

Definition at line 106 of file Eigen2Support/Geometry/Quaternion.h.

template<typename _Scalar>
Coefficients& Quaternion< _Scalar >::coeffs ( ) [inline]
Returns:
a vector expression of the coefficients (x,y,z,w)

Reimplemented from QuaternionBase< Quaternion< _Scalar, _Options > >.

Definition at line 109 of file Eigen2Support/Geometry/Quaternion.h.

template<typename _Scalar>
Coefficients& Quaternion< _Scalar >::coeffs ( ) [inline]
Returns:
a vector expression of the coefficients (x,y,z,w)

Reimplemented from QuaternionBase< Quaternion< _Scalar, _Options > >.

Definition at line 274 of file Geometry/Quaternion.h.

template<typename _Scalar>
const Coefficients& Quaternion< _Scalar >::coeffs ( ) const [inline]
Returns:
a read-only vector expression of the coefficients (x,y,z,w)

Reimplemented from QuaternionBase< Quaternion< _Scalar, _Options > >.

Definition at line 275 of file Geometry/Quaternion.h.

template<typename Scalar >
Quaternion< Scalar > Quaternion< Scalar >::conjugate ( void  ) const [inline]
Returns:
the conjugate of the *this which is equal to the multiplicative inverse if the quaternion is normalized. The conjugate of a quaternion represents the opposite rotation.
See also:
Quaternion::inverse()

Reimplemented from QuaternionBase< Quaternion< _Scalar, _Options > >.

Definition at line 408 of file Eigen2Support/Geometry/Quaternion.h.

template<typename _Scalar>
Scalar Quaternion< _Scalar >::eigen2_dot ( const Quaternion< _Scalar > &  other) const [inline]
Returns:
the dot product of *this and other Geometrically speaking, the dot product of two unit quaternions corresponds to the cosine of half the angle between the two rotations.
See also:
angularDistance()

Definition at line 174 of file Eigen2Support/Geometry/Quaternion.h.

template<typename _Scalar>
static Quaternion Quaternion< _Scalar >::Identity ( ) [inline, static]
Returns:
a quaternion representing an identity rotation
See also:
MatrixBase::Identity()

Reimplemented from QuaternionBase< Quaternion< _Scalar, _Options > >.

Definition at line 146 of file Eigen2Support/Geometry/Quaternion.h.

template<typename Scalar >
Quaternion< Scalar > Quaternion< Scalar >::inverse ( void  ) const [inline]
Returns:
the multiplicative inverse of *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.
See also:
Quaternion::conjugate()

Reimplemented from RotationBase< Quaternion< _Scalar >, 3 >.

Definition at line 388 of file Eigen2Support/Geometry/Quaternion.h.

template<typename _Scalar>
bool Quaternion< _Scalar >::isApprox ( const Quaternion< _Scalar > &  other,
typename NumTraits< Scalar >::Real  prec = precision<Scalar>() 
) const [inline]
Returns:
true if *this is approximately equal to other, within the precision determined by prec.
See also:
MatrixBase::isApprox()

Definition at line 212 of file Eigen2Support/Geometry/Quaternion.h.

template<typename _Scalar>
Scalar Quaternion< _Scalar >::norm ( ) const [inline]
Returns:
the norm of the quaternion's coefficients
See also:
Quaternion::squaredNorm(), MatrixBase::norm()

Reimplemented from QuaternionBase< Quaternion< _Scalar, _Options > >.

Definition at line 160 of file Eigen2Support/Geometry/Quaternion.h.

template<typename _Scalar>
void Quaternion< _Scalar >::normalize ( void  ) [inline]

Normalizes the quaternion *this

See also:
normalized(), MatrixBase::normalize()

Reimplemented from QuaternionBase< Quaternion< _Scalar, _Options > >.

Definition at line 164 of file Eigen2Support/Geometry/Quaternion.h.

template<typename _Scalar>
Quaternion Quaternion< _Scalar >::normalized ( ) const [inline]
Returns:
a normalized version of *this
See also:
normalize(), MatrixBase::normalized()

Reimplemented from QuaternionBase< Quaternion< _Scalar, _Options > >.

Definition at line 167 of file Eigen2Support/Geometry/Quaternion.h.

template<typename Scalar >
Quaternion< Scalar > Quaternion< Scalar >::operator* ( const Quaternion< _Scalar > &  other) const [inline]
Returns:
the concatenation of two rotations as a quaternion-quaternion product

Definition at line 241 of file Eigen2Support/Geometry/Quaternion.h.

template<typename Scalar >
template<typename Derived >
Quaternion< Scalar >::Vector3 Quaternion< Scalar >::operator* ( const MatrixBase< Derived > &  v) const [inline]

Rotation of a vector by a quaternion.

Remarks:
If the quaternion is used to rotate several points (>1) then it is much more efficient to first convert it to a 3x3 Matrix. Comparison of the operation cost for n transformations:

Definition at line 263 of file Eigen2Support/Geometry/Quaternion.h.

template<typename Scalar >
Quaternion< Scalar > & Quaternion< Scalar >::operator*= ( const Quaternion< _Scalar > &  other) [inline]
See also:
operator*(Quaternion)

Definition at line 248 of file Eigen2Support/Geometry/Quaternion.h.

template<typename Scalar >
Quaternion< Scalar > & Quaternion< Scalar >::operator= ( const Quaternion< _Scalar > &  other) [inline]

Definition at line 276 of file Eigen2Support/Geometry/Quaternion.h.

template<typename Scalar >
Quaternion< Scalar > & Quaternion< Scalar >::operator= ( const AngleAxisType aa) [inline]

Set *this from an angle-axis aa and returns a reference to *this

Reimplemented from QuaternionBase< Quaternion< _Scalar, _Options > >.

Definition at line 285 of file Eigen2Support/Geometry/Quaternion.h.

template<typename Scalar >
template<typename Derived >
Quaternion< Scalar > & Quaternion< Scalar >::operator= ( const MatrixBase< Derived > &  xpr) [inline]

Set *this from the expression xpr:

  • if xpr is a 4x1 vector, then xpr is assumed to be a quaternion
  • if xpr is a 3x3 matrix, then xpr is assumed to be rotation matrix and xpr is converted to a quaternion

Definition at line 300 of file Eigen2Support/Geometry/Quaternion.h.

template<typename Scalar >
template<typename Derived1 , typename Derived2 >
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.

Returns:
a reference to *this.

Note that the two input vectors do not have to be normalized.

Reimplemented from QuaternionBase< Quaternion< _Scalar, _Options > >.

Definition at line 351 of file Eigen2Support/Geometry/Quaternion.h.

template<typename _Scalar>
Quaternion& Quaternion< _Scalar >::setIdentity ( ) [inline]
template<typename Scalar >
Quaternion< Scalar > Quaternion< Scalar >::slerp ( Scalar  t,
const Quaternion< _Scalar > &  other 
) const
Returns:
the spherical linear interpolation between the two quaternions *this and other at the parameter t

Definition at line 429 of file Eigen2Support/Geometry/Quaternion.h.

template<typename _Scalar>
Scalar Quaternion< _Scalar >::squaredNorm ( ) const [inline]
Returns:
the squared norm of the quaternion's coefficients
See also:
Quaternion::norm(), MatrixBase::squaredNorm()

Reimplemented from QuaternionBase< Quaternion< _Scalar, _Options > >.

Definition at line 155 of file Eigen2Support/Geometry/Quaternion.h.

template<typename Scalar >
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 309 of file Eigen2Support/Geometry/Quaternion.h.

template<typename _Scalar>
const Block<const Coefficients,3,1> Quaternion< _Scalar >::vec ( ) const [inline]
Returns:
a read-only vector expression of the imaginary part (x,y,z)

Reimplemented from QuaternionBase< Quaternion< _Scalar, _Options > >.

Definition at line 100 of file Eigen2Support/Geometry/Quaternion.h.

template<typename _Scalar>
Block<Coefficients,3,1> Quaternion< _Scalar >::vec ( ) [inline]
Returns:
a vector expression of the imaginary part (x,y,z)

Reimplemented from QuaternionBase< Quaternion< _Scalar, _Options > >.

Definition at line 103 of file Eigen2Support/Geometry/Quaternion.h.

template<typename _Scalar>
Scalar Quaternion< _Scalar >::w ( ) const [inline]
Returns:
the w coefficient

Reimplemented from QuaternionBase< Quaternion< _Scalar, _Options > >.

Definition at line 88 of file Eigen2Support/Geometry/Quaternion.h.

template<typename _Scalar>
Scalar& Quaternion< _Scalar >::w ( ) [inline]
Returns:
a reference to the w coefficient

Reimplemented from QuaternionBase< Quaternion< _Scalar, _Options > >.

Definition at line 97 of file Eigen2Support/Geometry/Quaternion.h.

template<typename _Scalar>
Scalar Quaternion< _Scalar >::x ( ) const [inline]
Returns:
the x coefficient

Reimplemented from QuaternionBase< Quaternion< _Scalar, _Options > >.

Definition at line 82 of file Eigen2Support/Geometry/Quaternion.h.

template<typename _Scalar>
Scalar& Quaternion< _Scalar >::x ( ) [inline]
Returns:
a reference to the x coefficient

Reimplemented from QuaternionBase< Quaternion< _Scalar, _Options > >.

Definition at line 91 of file Eigen2Support/Geometry/Quaternion.h.

template<typename _Scalar>
Scalar Quaternion< _Scalar >::y ( ) const [inline]
Returns:
the y coefficient

Reimplemented from QuaternionBase< Quaternion< _Scalar, _Options > >.

Definition at line 84 of file Eigen2Support/Geometry/Quaternion.h.

template<typename _Scalar>
Scalar& Quaternion< _Scalar >::y ( ) [inline]
Returns:
a reference to the y coefficient

Reimplemented from QuaternionBase< Quaternion< _Scalar, _Options > >.

Definition at line 93 of file Eigen2Support/Geometry/Quaternion.h.

template<typename _Scalar>
Scalar Quaternion< _Scalar >::z ( ) const [inline]
Returns:
the z coefficient

Reimplemented from QuaternionBase< Quaternion< _Scalar, _Options > >.

Definition at line 86 of file Eigen2Support/Geometry/Quaternion.h.

template<typename _Scalar>
Scalar& Quaternion< _Scalar >::z ( ) [inline]
Returns:
a reference to the z coefficient

Reimplemented from QuaternionBase< Quaternion< _Scalar, _Options > >.

Definition at line 95 of file Eigen2Support/Geometry/Quaternion.h.


Member Data Documentation

template<typename _Scalar>
Coefficients Quaternion< _Scalar >::m_coeffs [protected]

Definition at line 216 of file Eigen2Support/Geometry/Quaternion.h.


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


libicr
Author(s): Robert Krug
autogenerated on Mon Jan 6 2014 11:34:24