Please, help us to better know about our user community by answering the following short survey:
Eigen  3.3.71
Eigen::Quaternion Class Reference

Detailed Description

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

This is defined in the Geometry module.

#include <Eigen/Geometry>
Template Parameters
_Scalarthe scalar type, i.e., the type of the coefficients
_Optionscontrols the memory alignment of the coefficients. Can be # AutoAlign or # DontAlign. Default is AutoAlign.

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, quaternions offer the following advantages:

  • compact storage (4 scalars)
  • efficient to compose (28 flops),
  • stable spherical interpolation

The following two typedefs are provided for convenience:

  • Quaternionf for float
  • Quaterniond for double
Operations interpreting the quaternion as rotation have undefined behavior if the quaternion is not normalized.
See also
class AngleAxis, class Transform

Public Member Functions

template<typename Derived1 , typename Derived2 >
Quaternion< Scalar, Options > FromTwoVectors (const MatrixBase< Derived1 > &a, const MatrixBase< Derived2 > &b)
template<class OtherDerived >
Derived & operator*= (const QuaternionBase< OtherDerived > &q)
 Quaternion ()
 Quaternion (const AngleAxisType &aa)
template<typename Derived >
 Quaternion (const MatrixBase< Derived > &other)
template<typename OtherScalar , int OtherOptions>
 Quaternion (const Quaternion< OtherScalar, OtherOptions > &other)
template<class Derived >
 Quaternion (const QuaternionBase< Derived > &other)
 Quaternion (const Scalar &w, const Scalar &x, const Scalar &y, const Scalar &z)
 Quaternion (const Scalar *data)

Static Public Member Functions

static Quaternion UnitRandom ()

Constructor & Destructor Documentation

◆ Quaternion() [1/7]

Eigen::Quaternion::Quaternion ( )

Default constructor leaving the quaternion uninitialized.

◆ Quaternion() [2/7]

Eigen::Quaternion::Quaternion ( const Scalar &  w,
const Scalar &  x,
const Scalar &  y,
const Scalar &  z 

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

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]

◆ Quaternion() [3/7]

Eigen::Quaternion::Quaternion ( const Scalar *  data)

Constructs and initialize a quaternion from the array data

◆ Quaternion() [4/7]

template<class Derived >
Eigen::Quaternion::Quaternion ( const QuaternionBase< Derived > &  other)

Copy constructor

◆ Quaternion() [5/7]

Eigen::Quaternion::Quaternion ( const AngleAxisType aa)

Constructs and initializes a quaternion from the angle-axis aa

◆ Quaternion() [6/7]

template<typename Derived >
Eigen::Quaternion::Quaternion ( const MatrixBase< Derived > &  other)

Constructs and initializes a quaternion from either:

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

◆ Quaternion() [7/7]

template<typename OtherScalar , int OtherOptions>
Eigen::Quaternion::Quaternion ( const Quaternion< OtherScalar, OtherOptions > &  other)

Explicit copy constructor with scalar conversion

Member Function Documentation

◆ FromTwoVectors()

template<typename Derived1 , typename Derived2 >
Quaternion<Scalar,Options> Eigen::Quaternion::FromTwoVectors ( const MatrixBase< Derived1 > &  a,
const MatrixBase< Derived2 > &  b 

Returns a quaternion representing a rotation between the two arbitrary vectors a and b. 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.

resulting quaternion

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

◆ operator*=()

template<class OtherDerived >
Derived & Eigen::QuaternionBase::operator*= ( class OtherDerived  )
See also

◆ UnitRandom()

Quaternion< Scalar, Options > Eigen::Quaternion::UnitRandom ( )
a random unit quaternion following a uniform distribution law on SO(3)
The implementation is based on

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