template<typename _Scalar, int _Options>
Eigen::Quaternion class

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

Template parameters
_Scalar the scalar type, i.e., the type of the coefficients
_Options controls the memory alignment of the coefficients. Can be # AutoAlign or # DontAlign. Default is AutoAlign.

This is defined in the Geometry module. #include <Eigen/Geometry>

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

Base classes

template<class Derived>
class QuaternionBase
Base class for quaternion expressions.

Public types

enum (anonymous) { }
using AngleAxisType = Base::AngleAxisType
using Base = QuaternionBase<Quaternion<_Scalar, _Options>>
using Coefficients = internal::traits<Quaternion>::Coefficients
using Scalar = _Scalar

Public static functions

template<typename Derived1, typename Derived2>
static auto FromTwoVectors(const MatrixBase<Derived1>& a, const MatrixBase<Derived2>& b) -> Quaternion
static auto UnitRandom() -> Quaternion

Constructors, destructors, conversion operators

Quaternion()
Quaternion(const Scalar& w, const Scalar& x, const Scalar& y, const Scalar& z)
Quaternion(const Scalar* data) explicit
template<class Derived>
Quaternion(const QuaternionBase<Derived>& other)
Quaternion(const AngleAxisType& aa) explicit
template<typename Derived>
Quaternion(const MatrixBase<Derived>& other) explicit
template<typename OtherScalar, int OtherOptions>
Quaternion(const Quaternion<OtherScalar, OtherOptions>& other) explicit

Public functions

auto coeffs() -> Coefficients&
auto coeffs() const -> const Coefficients&
template<typename Derived1, typename Derived2>
auto FromTwoVectors(const MatrixBase<Derived1>& a, const MatrixBase<Derived2>& b) -> Quaternion<Scalar, Options>

Protected variables

Coefficients m_coeffs

Enum documentation

template<typename _Scalar, int _Options>
enum Eigen::Quaternion<_Scalar, _Options>::(anonymous)

Typedef documentation

template<typename _Scalar, int _Options>
typedef Base::AngleAxisType Eigen::Quaternion<_Scalar, _Options>::AngleAxisType

template<typename _Scalar, int _Options>
typedef QuaternionBase<Quaternion<_Scalar, _Options>> Eigen::Quaternion<_Scalar, _Options>::Base

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

template<typename _Scalar, int _Options>
typedef _Scalar Eigen::Quaternion<_Scalar, _Options>::Scalar

Function documentation

template<typename _Scalar, int _Options> template<typename Derived1, typename Derived2>
static Quaternion Eigen::Quaternion<_Scalar, _Options>::FromTwoVectors(const MatrixBase<Derived1>& a, const MatrixBase<Derived2>& b)

template<typename _Scalar, int _Options>
static Quaternion Eigen::Quaternion<_Scalar, _Options>::UnitRandom()

Returns a random unit quaternion following a uniform distribution law on SO(3)

template<typename _Scalar, int _Options>
Eigen::Quaternion<_Scalar, _Options>::Quaternion()

Default constructor leaving the quaternion uninitialized.

template<typename _Scalar, int _Options>
Eigen::Quaternion<_Scalar, _Options>::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.

template<typename _Scalar, int _Options>
Eigen::Quaternion<_Scalar, _Options>::Quaternion(const Scalar* data) explicit

Constructs and initialize a quaternion from the array data

template<typename _Scalar, int _Options> template<class Derived>
Eigen::Quaternion<_Scalar, _Options>::Quaternion(const QuaternionBase<Derived>& other)

Copy constructor

template<typename _Scalar, int _Options>
Eigen::Quaternion<_Scalar, _Options>::Quaternion(const AngleAxisType& aa) explicit

Constructs and initializes a quaternion from the angle-axis aa

template<typename _Scalar, int _Options> template<typename Derived>
Eigen::Quaternion<_Scalar, _Options>::Quaternion(const MatrixBase<Derived>& other) explicit

Constructs and initializes a quaternion from either:

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

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

Explicit copy constructor with scalar conversion

template<typename _Scalar, int _Options>
Coefficients& Eigen::Quaternion<_Scalar, _Options>::coeffs()

template<typename _Scalar, int _Options>
const Coefficients& Eigen::Quaternion<_Scalar, _Options>::coeffs() const

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

Returns resulting quaternion

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.

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

Variable documentation

template<typename _Scalar, int _Options>
Coefficients Eigen::Quaternion<_Scalar, _Options>::m_coeffs protected