Kindr
Kinematics and Dynamics for Robotics
kindr::UnitQuaternion< PrimType_ > Class Template Reference

Implementation of a unit quaternion based on Eigen::Quaternion. More...

#include <Quaternion.hpp>

Inheritance diagram for kindr::UnitQuaternion< PrimType_ >:
Inheritance graph

Public Types

typedef Quaternion< PrimType_ >::Implementation Implementation
 the implementation type, i.e., Eigen::Quaternion<> More...
 
typedef PrimType_ Scalar
 the scalar type, i.e., the type of the coefficients More...
 
typedef Eigen::Matrix< PrimType_, 3, 1 > Imaginary
 the imaginary type, i.e., Eigen::Quaternion<> More...
 
typedef Eigen::Matrix< PrimType_, 4, 1 > Vector4
 quaternion as 4x1 matrix: [w; x; y; z] More...
 
- Public Types inherited from kindr::UnitQuaternionBase< UnitQuaternion< PrimType_ > >
typedef QuaternionBase< UnitQuaternion< PrimType_ > > Base
 

Public Member Functions

 UnitQuaternion ()
 Default Constructor initializes the unit quaternion to identity. More...
 
 UnitQuaternion (Scalar w, Scalar x, Scalar y, Scalar z)
 Constructor to create unit quaternion from coefficients. More...
 
 UnitQuaternion (Scalar real, const Imaginary &imag)
 Constructor using real and imaginary part. In debug mode, an assertion is thrown if the quaternion has not unit length. More...
 
 UnitQuaternion (const Vector4 &vector4)
 Constructor using Eigen::Matrix<PrimType_,4,1>. In debug mode, an assertion is thrown if the quaternion has not unit length. More...
 
 UnitQuaternion (const Quaternion< PrimType_ > &other)
 Constructor to create unit quaternion from Quaternion. More...
 
 UnitQuaternion (const Implementation &other)
 Constructor to create unit quaternion from Eigen::Quaternion. More...
 
UnitQuaternionoperator= (const UnitQuaternion< PrimType_ > &other)
 
template<typename PrimTypeIn_ >
UnitQuaternionoperator() (const UnitQuaternion< PrimTypeIn_ > &other)
 
template<typename PrimTypeIn_ >
UnitQuaternionoperator() (const Quaternion< PrimTypeIn_ > &other)
 
Scalar w () const
 
Scalar x () const
 
Scalar y () const
 
Scalar z () const
 
Scalarw ()
 
Scalarx ()
 
Scalary ()
 
Scalarz ()
 
Scalar real () const
 
Imaginary imaginary () const
 
Vector4 vector () const
 
UnitQuaternion conjugated () const
 
UnitQuaternionconjugate ()
 
Scalar norm () const
 
const ImplementationtoImplementation () const
 
ImplementationtoImplementation ()
 
Eigen::Matrix< PrimType_, 4, 4 > getQuaternionMatrix ()
 Returns the quaternion matrix Qleft: q*p = Qleft(q)*p This function can be used to get the derivative of the concatenation with respect to the right quaternion. More...
 
Eigen::Matrix< PrimType_, 4, 4 > getConjugateQuaternionMatrix ()
 Returns the quaternion matrix Qright: q*p = Qright(p)*q This function can be used to get the derivative of the concatenation with respect to the left quaternion. More...
 
- Public Member Functions inherited from kindr::UnitQuaternionBase< UnitQuaternion< PrimType_ > >
UnitQuaternion< PrimType_ > inverted () const
 gets the inverse of the unit quaternion using the conjugate More...
 
UnitQuaternion< PrimType_ > & invert ()
 inverts the unit quaternion using the conjugate More...
 
UnitQuaternion< PrimType_ > conjugated () const
 gets the conjugate of the quaternion More...
 
UnitQuaternion< PrimType_ > & conjugate ()
 conjugates the unit quaternion More...
 
UnitQuaternion< PrimType_ > operator* (const UnitQuaternionBase< OtherDerived_ > &other) const
 multiplies the unit quaternion with another unit quaternion More...
 
OtherDerived_ operator* (const QuaternionBase< OtherDerived_ > &other) const
 multiplies the unit quaternion with a quaternion More...
 
- Public Member Functions inherited from kindr::QuaternionBase< UnitQuaternion< PrimType_ > >
UnitQuaternion< PrimType_ > & invert ()
 inverts the quaternion More...
 
UnitQuaternion< PrimType_ > inverted () const
 gets the inverse of the quaternion More...
 
UnitQuaternion< PrimType_ > & conjugate ()
 conjugates the quaternion More...
 
UnitQuaternion< PrimType_ > conjugated () const
 gets the conjugate of the quaternion More...
 
 operator UnitQuaternion< PrimType_ > & ()
 gets the derived quaternion (only for advanced users) More...
 
 operator const UnitQuaternion< PrimType_ > & () const
 gets the derived quaternion (only for advanced users) More...
 
UnitQuaternion< PrimType_ > & derived ()
 gets the derived quaternion (only for advanced users) More...
 
const UnitQuaternion< PrimType_ > & derived () const
 gets the derived quaternion (only for advanced users) More...
 
UnitQuaternion< PrimType_ > operator* (const QuaternionBase< OtherDerived_ > &other) const
 multiplies the quaternion with another quaternion More...
 
bool operator== (const QuaternionBase< OtherDerived_ > &other) const
 compares the quaternion with another quaternion More...
 

Private Types

typedef UnitQuaternionBase< UnitQuaternion< PrimType_ > > Base
 

Private Attributes

Quaternion< PrimType_ > unitQuternion_
 

Detailed Description

template<typename PrimType_>
class kindr::UnitQuaternion< PrimType_ >

Implementation of a unit quaternion based on Eigen::Quaternion.

The Hamiltonian convention is used, where Q = w + x*i + y*j + z*k and i*i=j*j=k*k=ijk=-1.

The following two typedefs are provided for convenience:

  • UnitQuaternionF for float
  • UnitQuaternionD for double
See also
rm::Quaternion for an implementation of a generic quaternion
rm::rotations::RotationQuaternion for Quaternions that represent a rotation

Definition at line 40 of file Quaternion.hpp.

Member Typedef Documentation

◆ Base

template<typename PrimType_>
typedef UnitQuaternionBase<UnitQuaternion<PrimType_> > kindr::UnitQuaternion< PrimType_ >::Base
private

Definition at line 294 of file Quaternion.hpp.

◆ Imaginary

template<typename PrimType_>
typedef Eigen::Matrix<PrimType_,3,1> kindr::UnitQuaternion< PrimType_ >::Imaginary

the imaginary type, i.e., Eigen::Quaternion<>

Definition at line 301 of file Quaternion.hpp.

◆ Implementation

template<typename PrimType_>
typedef Quaternion<PrimType_>::Implementation kindr::UnitQuaternion< PrimType_ >::Implementation

the implementation type, i.e., Eigen::Quaternion<>

Definition at line 297 of file Quaternion.hpp.

◆ Scalar

template<typename PrimType_>
typedef PrimType_ kindr::UnitQuaternion< PrimType_ >::Scalar

the scalar type, i.e., the type of the coefficients

Definition at line 299 of file Quaternion.hpp.

◆ Vector4

template<typename PrimType_>
typedef Eigen::Matrix<PrimType_,4,1> kindr::UnitQuaternion< PrimType_ >::Vector4

quaternion as 4x1 matrix: [w; x; y; z]

Definition at line 303 of file Quaternion.hpp.

Constructor & Destructor Documentation

◆ UnitQuaternion() [1/6]

template<typename PrimType_>
kindr::UnitQuaternion< PrimType_ >::UnitQuaternion ( )
inline

Default Constructor initializes the unit quaternion to identity.

Definition at line 306 of file Quaternion.hpp.

◆ UnitQuaternion() [2/6]

template<typename PrimType_>
kindr::UnitQuaternion< PrimType_ >::UnitQuaternion ( Scalar  w,
Scalar  x,
Scalar  y,
Scalar  z 
)
inline

Constructor to create unit quaternion from coefficients.

Q = w + x*i + y*j + z*k

Parameters
wscalar
xvector index 1
yvector index 2
zvector index 3

Definition at line 317 of file Quaternion.hpp.

◆ UnitQuaternion() [3/6]

template<typename PrimType_>
kindr::UnitQuaternion< PrimType_ >::UnitQuaternion ( Scalar  real,
const Imaginary imag 
)
inline

Constructor using real and imaginary part. In debug mode, an assertion is thrown if the quaternion has not unit length.

Parameters
realreal part (PrimType_)
imagimaginary part (Eigen::Matrix<PrimType_,3,1>)

Definition at line 327 of file Quaternion.hpp.

◆ UnitQuaternion() [4/6]

template<typename PrimType_>
kindr::UnitQuaternion< PrimType_ >::UnitQuaternion ( const Vector4 vector4)
inline

Constructor using Eigen::Matrix<PrimType_,4,1>. In debug mode, an assertion is thrown if the quaternion has not unit length.

Parameters
otherEigen::Matrix<PrimType_,4,1>

Definition at line 336 of file Quaternion.hpp.

◆ UnitQuaternion() [5/6]

template<typename PrimType_>
kindr::UnitQuaternion< PrimType_ >::UnitQuaternion ( const Quaternion< PrimType_ > &  other)
inlineexplicit

Constructor to create unit quaternion from Quaternion.

Definition at line 342 of file Quaternion.hpp.

◆ UnitQuaternion() [6/6]

template<typename PrimType_>
kindr::UnitQuaternion< PrimType_ >::UnitQuaternion ( const Implementation other)
inlineexplicit

Constructor to create unit quaternion from Eigen::Quaternion.

Parameters
otherEigen::Quaternion

Definition at line 351 of file Quaternion.hpp.

Member Function Documentation

◆ conjugate()

template<typename PrimType_>
UnitQuaternion& kindr::UnitQuaternion< PrimType_ >::conjugate ( )
inline

the quaternion

Definition at line 459 of file Quaternion.hpp.

◆ conjugated()

template<typename PrimType_>
UnitQuaternion kindr::UnitQuaternion< PrimType_ >::conjugated ( ) const
inline
Returns
the conjugate of the quaternion

Definition at line 453 of file Quaternion.hpp.

◆ getConjugateQuaternionMatrix()

template<typename PrimType_>
Eigen::Matrix<PrimType_,4,4> kindr::UnitQuaternion< PrimType_ >::getConjugateQuaternionMatrix ( )
inline

Returns the quaternion matrix Qright: q*p = Qright(p)*q This function can be used to get the derivative of the concatenation with respect to the left quaternion.

Returns
the quaternion matrix Qright

Definition at line 502 of file Quaternion.hpp.

◆ getQuaternionMatrix()

template<typename PrimType_>
Eigen::Matrix<PrimType_,4,4> kindr::UnitQuaternion< PrimType_ >::getQuaternionMatrix ( )
inline

Returns the quaternion matrix Qleft: q*p = Qleft(q)*p This function can be used to get the derivative of the concatenation with respect to the right quaternion.

Returns
the quaternion matrix Qleft

Definition at line 489 of file Quaternion.hpp.

◆ imaginary()

template<typename PrimType_>
Imaginary kindr::UnitQuaternion< PrimType_ >::imaginary ( ) const
inline

Definition at line 437 of file Quaternion.hpp.

◆ norm()

template<typename PrimType_>
Scalar kindr::UnitQuaternion< PrimType_ >::norm ( ) const
inline
Returns
the inverse of the quaternion which is the conjugate for unit quaternions

Definition at line 473 of file Quaternion.hpp.

◆ operator()() [1/2]

template<typename PrimType_>
template<typename PrimTypeIn_ >
UnitQuaternion& kindr::UnitQuaternion< PrimType_ >::operator() ( const UnitQuaternion< PrimTypeIn_ > &  other)
inline

Definition at line 365 of file Quaternion.hpp.

◆ operator()() [2/2]

template<typename PrimType_>
template<typename PrimTypeIn_ >
UnitQuaternion& kindr::UnitQuaternion< PrimType_ >::operator() ( const Quaternion< PrimTypeIn_ > &  other)
inline

Definition at line 375 of file Quaternion.hpp.

◆ operator=()

template<typename PrimType_>
UnitQuaternion& kindr::UnitQuaternion< PrimType_ >::operator= ( const UnitQuaternion< PrimType_ > &  other)
inline

Definition at line 356 of file Quaternion.hpp.

◆ real()

template<typename PrimType_>
Scalar kindr::UnitQuaternion< PrimType_ >::real ( ) const
inline

Definition at line 433 of file Quaternion.hpp.

◆ toImplementation() [1/2]

template<typename PrimType_>
const Implementation& kindr::UnitQuaternion< PrimType_ >::toImplementation ( ) const
inline

Definition at line 477 of file Quaternion.hpp.

◆ toImplementation() [2/2]

template<typename PrimType_>
Implementation& kindr::UnitQuaternion< PrimType_ >::toImplementation ( )
inline

Definition at line 481 of file Quaternion.hpp.

◆ vector()

template<typename PrimType_>
Vector4 kindr::UnitQuaternion< PrimType_ >::vector ( ) const
inline

Definition at line 441 of file Quaternion.hpp.

◆ w() [1/2]

template<typename PrimType_>
Scalar kindr::UnitQuaternion< PrimType_ >::w ( ) const
inline

Definition at line 401 of file Quaternion.hpp.

◆ w() [2/2]

template<typename PrimType_>
Scalar& kindr::UnitQuaternion< PrimType_ >::w ( )
inline

Definition at line 417 of file Quaternion.hpp.

◆ x() [1/2]

template<typename PrimType_>
Scalar kindr::UnitQuaternion< PrimType_ >::x ( ) const
inline

Definition at line 405 of file Quaternion.hpp.

◆ x() [2/2]

template<typename PrimType_>
Scalar& kindr::UnitQuaternion< PrimType_ >::x ( )
inline

Definition at line 421 of file Quaternion.hpp.

◆ y() [1/2]

template<typename PrimType_>
Scalar kindr::UnitQuaternion< PrimType_ >::y ( ) const
inline

Definition at line 409 of file Quaternion.hpp.

◆ y() [2/2]

template<typename PrimType_>
Scalar& kindr::UnitQuaternion< PrimType_ >::y ( )
inline

Definition at line 425 of file Quaternion.hpp.

◆ z() [1/2]

template<typename PrimType_>
Scalar kindr::UnitQuaternion< PrimType_ >::z ( ) const
inline

Definition at line 413 of file Quaternion.hpp.

◆ z() [2/2]

template<typename PrimType_>
Scalar& kindr::UnitQuaternion< PrimType_ >::z ( )
inline

Definition at line 429 of file Quaternion.hpp.

Member Data Documentation

◆ unitQuternion_

template<typename PrimType_>
Quaternion<PrimType_> kindr::UnitQuaternion< PrimType_ >::unitQuternion_
private

Definition at line 293 of file Quaternion.hpp.


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