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

Implementation of matrix rotation based on Eigen::Matrix<Scalar, 3, 3> More...

#include <Rotation.hpp>

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

Public Types

typedef Base Implementation
 The implementation type. The implementation type is always an Eigen object. More...
 
typedef PrimType_ Scalar
 The primitive type. Float/Double. More...
 

Public Member Functions

 RotationMatrix ()
 Default constructor using identity rotation. More...
 
 RotationMatrix (Scalar r11, Scalar r12, Scalar r13, Scalar r21, Scalar r22, Scalar r23, Scalar r31, Scalar r32, Scalar r33)
 Constructor using nine scalars. In debug mode, an assertion is thrown if the matrix is not a rotation matrix. More...
 
 RotationMatrix (const Base &other)
 Constructor using Eigen::Matrix. In debug mode, an assertion is thrown if the rotation vector has not unit length. More...
 
template<typename OtherDerived_ >
 RotationMatrix (const RotationBase< OtherDerived_ > &other)
 Constructor using another rotation. More...
 
template<typename OtherDerived_ >
RotationMatrixoperator= (const RotationBase< OtherDerived_ > &other)
 Assignment operator using another rotation. More...
 
template<typename OtherDerived_ >
RotationMatrixoperator() (const RotationBase< OtherDerived_ > &other)
 Parenthesis operator to convert from another rotation. More...
 
RotationMatrix inverted () const
 Returns the inverse of the rotation. More...
 
RotationMatrixinvert ()
 Inverts the rotation. More...
 
RotationMatrix transposed () const
 Returns the transpose of the rotation matrix. More...
 
RotationMatrixtranspose ()
 Transposes the rotation matrix. More...
 
Scalar determinant () const
 Returns the determinant of the rotation matrix. More...
 
ImplementationtoImplementation ()
 Cast to the implementation type. More...
 
const ImplementationtoImplementation () const
 Cast to the implementation type. More...
 
Implementation matrix () const
 Reading access to the rotation matrix. More...
 
void setMatrix (const Implementation &input)
 Writing access to the rotation matrix. More...
 
void setMatrix (Scalar r11, Scalar r12, Scalar r13, Scalar r21, Scalar r22, Scalar r23, Scalar r31, Scalar r32, Scalar r33)
 Writing access to the rotation matrix. More...
 
RotationMatrixsetIdentity ()
 Sets the rotation to identity. More...
 
RotationMatrix getUnique () const
 Returns a unique matrix rotation. A rotation matrix is always unique. This function is used to compare different rotations. More...
 
RotationMatrixsetUnique ()
 Modifies the matrix rotation such that it becomes unique. A rotation matrix is always unique. More...
 
- Public Member Functions inherited from kindr::RotationBase< RotationMatrix< PrimType_ > >
 RotationBase ()=default
 Standard constructor. Creates an empty generic rotation object. More...
 
 RotationBase (const RotationMatrix< PrimType_ > &)=delete
 Constructor from derived rotation. This constructor has been deleted because the abstract class does not contain any data. More...
 
RotationBase inverted () const
 Returns the inverse of the rotation. More...
 
RotationBaseinvert ()
 Inverts the rotation. More...
 
 operator RotationMatrix< PrimType_ > & ()
 Gets the derived rotation. (only for advanced users) More...
 
 operator const RotationMatrix< PrimType_ > & () const
 Gets the derived rotation. (only for advanced users) More...
 
RotationMatrix< PrimType_ > & derived ()
 Gets the derived rotation. (only for advanced users) More...
 
const RotationMatrix< PrimType_ > & derived () const
 Gets the derived rotation. (only for advanced users) More...
 
RotationMatrix< PrimType_ > & setIdentity ()
 Sets the rotation to the identity rotation. More...
 
RotationMatrix< PrimType_ > & setRandom ()
 Sets the rotation to a random one. More...
 
RotationMatrix< PrimType_ > getRandom () const
 Returns a random rotation. More...
 
RotationMatrix< PrimType_ > getUnique () const
 Returns the rotation in a unique form This function is used to compare different rotations. More...
 
RotationMatrix< PrimType_ > & setUnique ()
 Modifies the rotation such that it is in its unique form. More...
 
RotationMatrix< PrimType_ > operator* (const RotationBase< OtherDerived_ > &other) const
 Concatenates two rotations. More...
 
bool operator== (const RotationBase< OtherDerived_ > &other) const
 Compares two rotations. More...
 
internal::get_scalar< RotationMatrix< PrimType_ > >::Scalar getDisparityAngle (const RotationBase< OtherDerived_ > &other) const
 Gets the disparity angle between two rotations for comparison. More...
 
bool isNear (const RotationBase< OtherDerived_ > &other, typename internal::get_scalar< RotationMatrix< PrimType_ > >::Scalar tol) const
 Compares two rotations with a tolerance. More...
 
internal::get_matrix3X< RotationMatrix< PrimType_ > >::template Matrix3X< Cols > rotate (const typename internal::get_matrix3X< RotationMatrix< PrimType_ > >::template Matrix3X< Cols > &matrix) const
 Rotates a vector or a matrix column-wise. More...
 
Vector_ rotate (const Vector_ &vector) const
 Rotates a vector. More...
 
internal::get_matrix3X< RotationMatrix< PrimType_ > >::template Matrix3X< Cols > inverseRotate (const typename internal::get_matrix3X< RotationMatrix< PrimType_ > >::template Matrix3X< Cols > &matrix) const
 Rotates a vector or matrix in reverse. More...
 
Vector_ inverseRotate (const Vector_ &vector) const
 Rotates a vector in reverse. More...
 
RotationMatrix< PrimType_ > exponentialMap (const typename internal::get_matrix3X< RotationMatrix< PrimType_ > >::template Matrix3X< 1 > &vector)
 Sets the rotation using an exponential map. More...
 
internal::get_matrix3X< RotationMatrix< PrimType_ > >::template Matrix3X< 1 > logarithmicMap () const
 Gets the logarithmic map from the rotation. More...
 
internal::get_matrix3X< RotationMatrix< PrimType_ > >::template Matrix3X< 1 > boxMinus (const RotationBase< OtherDerived_ > &other) const
 Applies the box minus operation. More...
 
RotationMatrix< PrimType_ > boxPlus (const typename internal::get_matrix3X< RotationMatrix< PrimType_ > >::template Matrix3X< 1 > &vector) const
 Applies the box plus operation. More...
 
RotationMatrix< PrimType_ > & setFromVectors (const Vector_ &B_v, const Vector_ &I_v)
 Sets the rotation C_IB from two vectors such that I_v = C_IB*B_v i.e. I_v = this->rotate(B_v). More...
 
void fix ()
 Fixes the rotation to get rid of numerical errors (e.g. normalize quaternion). More...
 

Private Types

typedef Eigen::Matrix< PrimType_, 3, 3 > Base
 The base type. More...
 

Friends

std::ostream & operator<< (std::ostream &out, const RotationMatrix &rotationMatrix)
 Used for printing the object with std::cout. More...
 

Detailed Description

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

Implementation of matrix rotation based on Eigen::Matrix<Scalar, 3, 3>

The following four typedefs are provided for convenience:

  • RotationMatrixD for double primitive type
  • RotationMatrixF for float primitive type
Template Parameters
PrimType_the primitive type of the data (double or float)

Definition at line 49 of file Rotation.hpp.

Member Typedef Documentation

template<typename PrimType_>
typedef Eigen::Matrix<PrimType_, 3, 3> kindr::RotationMatrix< PrimType_ >::Base
private

The base type.

Definition at line 58 of file RotationMatrix.hpp.

template<typename PrimType_>
typedef Base kindr::RotationMatrix< PrimType_ >::Implementation

The implementation type. The implementation type is always an Eigen object.

Definition at line 63 of file RotationMatrix.hpp.

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

The primitive type. Float/Double.

Definition at line 67 of file RotationMatrix.hpp.

Constructor & Destructor Documentation

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

Default constructor using identity rotation.

Definition at line 71 of file RotationMatrix.hpp.

template<typename PrimType_>
kindr::RotationMatrix< PrimType_ >::RotationMatrix ( Scalar  r11,
Scalar  r12,
Scalar  r13,
Scalar  r21,
Scalar  r22,
Scalar  r23,
Scalar  r31,
Scalar  r32,
Scalar  r33 
)
inline

Constructor using nine scalars. In debug mode, an assertion is thrown if the matrix is not a rotation matrix.

Parameters
r11entry in row 1, col 1
r12entry in row 1, col 2
r13entry in row 1, col 3
r21entry in row 2, col 1
r22entry in row 2, col 2
r23entry in row 2, col 3
r31entry in row 3, col 1
r32entry in row 3, col 2
r33entry in row 3, col 3

Definition at line 87 of file RotationMatrix.hpp.

template<typename PrimType_>
kindr::RotationMatrix< PrimType_ >::RotationMatrix ( const Base other)
inlineexplicit

Constructor using Eigen::Matrix. In debug mode, an assertion is thrown if the rotation vector has not unit length.

Parameters
otherEigen::Matrix<PrimType_,3,3>

Definition at line 101 of file RotationMatrix.hpp.

template<typename PrimType_>
template<typename OtherDerived_ >
kindr::RotationMatrix< PrimType_ >::RotationMatrix ( const RotationBase< OtherDerived_ > &  other)
inlineexplicit

Constructor using another rotation.

Parameters
otherother rotation

Definition at line 115 of file RotationMatrix.hpp.

Member Function Documentation

template<typename PrimType_>
Scalar kindr::RotationMatrix< PrimType_ >::determinant ( ) const
inline

Returns the determinant of the rotation matrix.

Returns
determinant of the rotation matrix

Definition at line 178 of file RotationMatrix.hpp.

template<typename PrimType_>
RotationMatrix kindr::RotationMatrix< PrimType_ >::getUnique ( ) const
inline

Returns a unique matrix rotation. A rotation matrix is always unique. This function is used to compare different rotations.

Returns
copy of the matrix rotation which is unique

Definition at line 232 of file RotationMatrix.hpp.

template<typename PrimType_>
RotationMatrix& kindr::RotationMatrix< PrimType_ >::invert ( )
inline

Inverts the rotation.

Returns
reference

Definition at line 153 of file RotationMatrix.hpp.

template<typename PrimType_>
RotationMatrix kindr::RotationMatrix< PrimType_ >::inverted ( ) const
inline

Returns the inverse of the rotation.

Returns
the inverse of the rotation

Definition at line 144 of file RotationMatrix.hpp.

template<typename PrimType_>
Implementation kindr::RotationMatrix< PrimType_ >::matrix ( ) const
inline

Reading access to the rotation matrix.

Returns
rotation matrix (matrix) with reading access

Definition at line 199 of file RotationMatrix.hpp.

template<typename PrimType_>
template<typename OtherDerived_ >
RotationMatrix& kindr::RotationMatrix< PrimType_ >::operator() ( const RotationBase< OtherDerived_ > &  other)
inline

Parenthesis operator to convert from another rotation.

Parameters
otherother rotation
Returns
reference

Definition at line 136 of file RotationMatrix.hpp.

template<typename PrimType_>
template<typename OtherDerived_ >
RotationMatrix& kindr::RotationMatrix< PrimType_ >::operator= ( const RotationBase< OtherDerived_ > &  other)
inline

Assignment operator using another rotation.

Parameters
otherother rotation
Returns
referece

Definition at line 126 of file RotationMatrix.hpp.

template<typename PrimType_>
RotationMatrix& kindr::RotationMatrix< PrimType_ >::setIdentity ( )
inline

Sets the rotation to identity.

Returns
reference

Definition at line 222 of file RotationMatrix.hpp.

template<typename PrimType_>
void kindr::RotationMatrix< PrimType_ >::setMatrix ( const Implementation input)
inline

Writing access to the rotation matrix.

Definition at line 205 of file RotationMatrix.hpp.

template<typename PrimType_>
void kindr::RotationMatrix< PrimType_ >::setMatrix ( Scalar  r11,
Scalar  r12,
Scalar  r13,
Scalar  r21,
Scalar  r22,
Scalar  r23,
Scalar  r31,
Scalar  r32,
Scalar  r33 
)
inline

Writing access to the rotation matrix.

Definition at line 211 of file RotationMatrix.hpp.

template<typename PrimType_>
RotationMatrix& kindr::RotationMatrix< PrimType_ >::setUnique ( )
inline

Modifies the matrix rotation such that it becomes unique. A rotation matrix is always unique.

Returns
reference

Definition at line 240 of file RotationMatrix.hpp.

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

Cast to the implementation type.

Returns
the implementation for direct manipulation (recommended only for advanced users)

Definition at line 185 of file RotationMatrix.hpp.

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

Cast to the implementation type.

Returns
the implementation for direct manipulation (recommended only for advanced users)

Definition at line 192 of file RotationMatrix.hpp.

template<typename PrimType_>
RotationMatrix& kindr::RotationMatrix< PrimType_ >::transpose ( )
inline

Transposes the rotation matrix.

Returns
reference

Definition at line 170 of file RotationMatrix.hpp.

template<typename PrimType_>
RotationMatrix kindr::RotationMatrix< PrimType_ >::transposed ( ) const
inline

Returns the transpose of the rotation matrix.

Returns
the inverse of the rotation

Definition at line 161 of file RotationMatrix.hpp.

Friends And Related Function Documentation

template<typename PrimType_>
std::ostream& operator<< ( std::ostream &  out,
const RotationMatrix< PrimType_ > &  rotationMatrix 
)
friend

Used for printing the object with std::cout.

Returns
std::stream object

Definition at line 259 of file RotationMatrix.hpp.


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