Main MRPT website > C++ reference
MRPT logo
Public Types | Public Member Functions | Static Public Member Functions | Protected Attributes | Private Types
Eigen::Quaternion Class Reference

Detailed Description

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
Inheritance diagram for Eigen::Quaternion:
Inheritance graph
[legend]

List of all members.

Public Types

typedef _Scalar Scalar
typedef internal::traits
< Quaternion< Scalar, _Options >
>::Coefficients 
Coefficients
typedef Base::AngleAxisType AngleAxisType
 the equivalent angle-axis type
enum  
typedef NumTraits< Scalar >::Real RealScalar
typedef Matrix< Scalar, 3, 1 > Vector3
 the type of a 3D vector
typedef Matrix< Scalar, 3, 3 > Matrix3
 the equivalent rotation matrix type

Public Member Functions

 Quaternion ()
 Default constructor leaving the quaternion uninitialized.
 Quaternion (Scalar w, Scalar x, Scalar y, Scalar z)
 Constructs and initializes the quaternion $ w+xi+yj+zk $ from its four coefficients w, x, y and z.
 Quaternion (const Scalar *data)
 Constructs and initialize a quaternion from the array data.
template<class Derived >
EIGEN_STRONG_INLINE Quaternion (const QuaternionBase< Derived > &other)
 Copy constructor.
 Quaternion (const AngleAxisType &aa)
 Constructs and initializes a quaternion from the angle-axis aa.
template<typename Derived >
 Quaternion (const MatrixBase< Derived > &other)
 Constructs and initializes a quaternion from either:
Coefficientscoeffs ()
const Coefficientscoeffs () const
Scalar x () const
Scalarx ()
Scalar y () const
Scalary ()
Scalar z () const
Scalarz ()
Scalar w () const
Scalarw ()
const VectorBlock< const
Coefficients, 3 > 
vec () const
VectorBlock< Coefficients, 3 > vec ()
QuaternionBasesetIdentity ()
Scalar squaredNorm () const
Scalar norm () const
void normalize ()
 Normalizes the quaternion *this.
Quaternion< Scalarnormalized () const
Scalar dot (const QuaternionBase< OtherDerived > &other) const
Scalar angularDistance (const QuaternionBase< OtherDerived > &other) const
Matrix3 toRotationMatrix () const
Derived & setFromTwoVectors (const MatrixBase< Derived1 > &a, const MatrixBase< Derived2 > &b)
EIGEN_STRONG_INLINE Quaternion
< Scalar
operator* (const QuaternionBase< OtherDerived > &q) const
EIGEN_STRONG_INLINE Derived & operator*= (const QuaternionBase< OtherDerived > &q)
Quaternion< Scalarinverse () const
Quaternion< Scalarconjugate () const
Quaternion< Scalarslerp (Scalar t, const QuaternionBase< OtherDerived > &other) const
bool isApprox (const QuaternionBase< OtherDerived > &other, RealScalar prec=NumTraits< Scalar >::dummy_precision()) const
EIGEN_STRONG_INLINE Vector3 _transformVector (Vector3 v) const
 return the result vector of v through the rotation
internal::cast_return_type
< Derived, Quaternion
< NewScalarType > >::type 
cast () const

Static Public Member Functions

static Quaternion< ScalarIdentity ()

Protected Attributes

Coefficients m_coeffs

Private Types

typedef QuaternionBase
< Quaternion< _Scalar,
_Options > > 
Base

Member Typedef Documentation

the equivalent angle-axis type

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

Definition at line 245 of file Geometry.

typedef QuaternionBase<Quaternion<_Scalar,_Options> > Eigen::Quaternion::Base [private]

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

Definition at line 237 of file Geometry.

typedef internal::traits<Quaternion<Scalar,_Options> >::Coefficients Eigen::Quaternion::Coefficients

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

Definition at line 244 of file Geometry.

typedef Matrix<Scalar,3,3> Eigen::QuaternionBase::Matrix3 [inherited]

the equivalent rotation matrix type

Definition at line 61 of file Geometry.

Definition at line 51 of file Geometry.

typedef _Scalar Eigen::Quaternion::Scalar

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

Definition at line 239 of file Geometry.

typedef Matrix<Scalar,3,1> Eigen::QuaternionBase::Vector3 [inherited]

the type of a 3D vector

Definition at line 59 of file Geometry.


Member Enumeration Documentation

anonymous enum [inherited]

Definition at line 53 of file Geometry.


Constructor & Destructor Documentation

Eigen::Quaternion::Quaternion ( ) [inline]

Default constructor leaving the quaternion uninitialized.

Definition at line 248 of file Geometry.

Eigen::Quaternion::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 257 of file Geometry.

Eigen::Quaternion::Quaternion ( const Scalar data) [inline]

Constructs and initialize a quaternion from the array data.

Definition at line 260 of file Geometry.

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

Copy constructor.

Definition at line 263 of file Geometry.

Eigen::Quaternion::Quaternion ( const AngleAxisType aa) [inline, explicit]

Constructs and initializes a quaternion from the angle-axis aa.

Definition at line 266 of file Geometry.

template<typename Derived >
Eigen::Quaternion::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 273 of file Geometry.


Member Function Documentation

EIGEN_STRONG_INLINE Vector3 Eigen::QuaternionBase::_transformVector ( Vector3  v) const [inherited]

return the result vector of v through the rotation

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:
  • Quaternion2: 30n
  • Via a Matrix3: 24 + 15n
Scalar Eigen::QuaternionBase::angularDistance ( const QuaternionBase< OtherDerived > &  other) const [inherited]
Returns:
the angle (in radian) between two rotations
See also:
dot()
internal::cast_return_type<Derived,Quaternion<NewScalarType> >::type Eigen::QuaternionBase::cast ( ) const [inline, inherited]
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.

Definition at line 184 of file Geometry.

Coefficients& Eigen::Quaternion::coeffs ( ) [inline]
Returns:
a vector expression of the coefficients (x,y,z,w)

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

Definition at line 275 of file Geometry.

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

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

Definition at line 276 of file Geometry.

Quaternion<Scalar> Eigen::QuaternionBase::conjugate ( ) const [inherited]
Returns:
the conjugated quaternion
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:
Quaternion2::inverse()
Scalar Eigen::QuaternionBase::dot ( const QuaternionBase< OtherDerived > &  other) const [inline, inherited]
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 141 of file Geometry.

static Quaternion<Scalar> Eigen::QuaternionBase::Identity ( ) [inline, static, inherited]
Returns:
a quaternion representing an identity rotation
See also:
MatrixBase::Identity()

Definition at line 113 of file Geometry.

Quaternion<Scalar> Eigen::QuaternionBase::inverse ( ) const [inherited]
Returns:
the quaternion describing the inverse rotation
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:
QuaternionBase::conjugate()
bool Eigen::QuaternionBase::isApprox ( const QuaternionBase< OtherDerived > &  other,
RealScalar  prec = NumTraits<Scalar>::dummy_precision() 
) const [inline, inherited]
Returns:
true if *this is approximately equal to other, within the precision determined by prec.
See also:
MatrixBase::isApprox()

Definition at line 172 of file Geometry.

Scalar Eigen::QuaternionBase::norm ( ) const [inline, inherited]
Returns:
the norm of the quaternion's coefficients
See also:
QuaternionBase::squaredNorm(), MatrixBase::norm()

Definition at line 127 of file Geometry.

void Eigen::QuaternionBase::normalize ( void  ) [inline, inherited]

Normalizes the quaternion *this.

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

Definition at line 131 of file Geometry.

Quaternion<Scalar> Eigen::QuaternionBase::normalized ( ) const [inline, inherited]
Returns:
a normalized copy of *this
See also:
normalize(), MatrixBase::normalized()

Definition at line 134 of file Geometry.

EIGEN_STRONG_INLINE Quaternion<Scalar> Eigen::QuaternionBase::operator* ( const QuaternionBase< OtherDerived > &  q) const [inherited]
Returns:
the concatenation of two rotations as a quaternion-quaternion product
EIGEN_STRONG_INLINE Derived& Eigen::QuaternionBase::operator*= ( const QuaternionBase< OtherDerived > &  q) [inherited]
See also:
operator*(Quaternion)
Derived& Eigen::QuaternionBase::setFromTwoVectors ( const MatrixBase< Derived1 > &  a,
const MatrixBase< Derived2 > &  b 
) [inherited]

Sets *this to be a quaternion representing a rotation between the two arbitrary vectors a and b.

Returns:
the quaternion which transform a into b through a rotation

In other words, the built rotation represent a rotation sending the line of direction a to the line of direction b, both lines passing through the origin.

Returns:
a reference to *this.

Note that the two input vectors do not have to be normalized, and do not need to have the same norm.

QuaternionBase& Eigen::QuaternionBase::setIdentity ( ) [inline, inherited]
See also:
QuaternionBase::Identity(), MatrixBase::setIdentity()

Definition at line 117 of file Geometry.

Quaternion<Scalar> Eigen::QuaternionBase::slerp ( Scalar  t,
const QuaternionBase< OtherDerived > &  other 
) const [inherited]
Returns:
an interpolation for a constant motion between other and *this t in [0;1] see http://en.wikipedia.org/wiki/Slerp
the spherical linear interpolation between the two quaternions *this and other at the parameter t
Scalar Eigen::QuaternionBase::squaredNorm ( ) const [inline, inherited]
Returns:
the squared norm of the quaternion's coefficients
See also:
QuaternionBase::norm(), MatrixBase::squaredNorm()

Definition at line 122 of file Geometry.

Matrix3 Eigen::QuaternionBase::toRotationMatrix ( ) const [inherited]

Convert the quaternion to a 3x3 rotation matrix.

Returns:
an equivalent 3x3 rotation matrix

The quaternion is required to be normalized, otherwise the result is undefined.

const VectorBlock<const Coefficients,3> Eigen::QuaternionBase::vec ( ) const [inline, inherited]
Returns:
a read-only vector expression of the imaginary part (x,y,z)

Definition at line 86 of file Geometry.

VectorBlock<Coefficients,3> Eigen::QuaternionBase::vec ( ) [inline, inherited]
Returns:
a vector expression of the imaginary part (x,y,z)

Definition at line 89 of file Geometry.

Scalar Eigen::QuaternionBase::w ( ) const [inline, inherited]
Returns:
the w coefficient

Definition at line 74 of file Geometry.

Scalar& Eigen::QuaternionBase::w ( ) [inline, inherited]
Returns:
a reference to the w coefficient

Definition at line 83 of file Geometry.

Scalar Eigen::QuaternionBase::x ( ) const [inline, inherited]
Returns:
the x coefficient

Definition at line 68 of file Geometry.

Scalar& Eigen::QuaternionBase::x ( ) [inline, inherited]
Returns:
a reference to the x coefficient

Definition at line 77 of file Geometry.

Scalar Eigen::QuaternionBase::y ( ) const [inline, inherited]
Returns:
the y coefficient

Definition at line 70 of file Geometry.

Scalar& Eigen::QuaternionBase::y ( ) [inline, inherited]
Returns:
a reference to the y coefficient

Definition at line 79 of file Geometry.

Scalar Eigen::QuaternionBase::z ( ) const [inline, inherited]
Returns:
the z coefficient

Definition at line 72 of file Geometry.

Scalar& Eigen::QuaternionBase::z ( ) [inline, inherited]
Returns:
a reference to the z coefficient

Definition at line 81 of file Geometry.


Member Data Documentation

Definition at line 279 of file Geometry.




Page generated by Doxygen 1.7.5 for MRPT 0.9.5 SVN: at Thu Oct 13 21:25:36 UTC 2011