RobWorkProject
Public Types | Public Member Functions | Static Public Member Functions | Related Functions | List of all members
Rotation3D< T > Class Template Reference

A 3x3 rotation matrix $ \mathbf{R}\in SO(3) $. More...

#include <Rotation3D.hpp>

Public Types

typedef T value_type
 Value type.
 
typedef boost::numeric::ublas::bounded_matrix< T, 3, 3 > BoostMatrix3x3
 Type for the legacy Boost matrix implementation.
 
typedef Eigen::Matrix< T, 3, 3 > EigenMatrix3x3
 The type of the internal Eigen matrix implementation.
 

Public Member Functions

 Rotation3D ()
 A rotation matrix with uninitialized storage.
 
 Rotation3D (T r11, T r12, T r13, T r21, T r22, T r23, T r31, T r32, T r33)
 Constructs an initialized 3x3 rotation matrix. More...
 
 Rotation3D (const Vector3D< T > &i, const Vector3D< T > &j, const Vector3D< T > &k)
 Constructs an initialized 3x3 rotation matrix $ \robabx{a}{b}{\mathbf{R}} = \left[ \begin{array}{ccc} \robabx{a}{b}{\mathbf{i}} & \robabx{a}{b}{\mathbf{j}} & \robabx{a}{b}{\mathbf{k}} \end{array} \right] $. More...
 
void normalize ()
 Normalizes the rotation matrix to satisfy SO(3). More...
 
T & operator() (size_t row, size_t column)
 Returns reference to matrix element. More...
 
const T & operator() (size_t row, size_t column) const
 Returns reference to matrix element. More...
 
const Vector3D< T > getRow (size_t i) const
 Returns the i'th row of the rotation matrix. More...
 
const Vector3D< T > getCol (size_t i) const
 Returns the i'th column of the rotation matrix. More...
 
bool operator== (const Rotation3D< T > &rhs) const
 Comparison operator. More...
 
bool operator!= (const Rotation3D< T > &rhs) const
 Comparison operator. More...
 
bool equal (const Rotation3D< T > &rot, const T precision=std::numeric_limits< T >::epsilon()) const
 Compares rotations with a given precision. More...
 
bool isProperRotation () const
 Verify that this rotation is a proper rotation. More...
 
bool isProperRotation (T precision) const
 Verify that this rotation is a proper rotation. More...
 
BoostMatrix3x3 m () const
 Returns a Boost 3x3 matrix $ \mathbf{M}\in SO(3) $ that represents this rotation. More...
 
EigenMatrix3x3 e () const
 Returns a Eigen 3x3 matrix $ \mathbf{M}\in SO(3) $ that represents this rotation. More...
 
const Rotation3D operator* (const Rotation3D &bRc) const
 Calculates $ \robabx{a}{c}{\mathbf{R}} = \robabx{a}{b}{\mathbf{R}} \robabx{b}{c}{\mathbf{R}} $. More...
 
const Vector3D< T > operator* (const Vector3D< T > &bVc) const
 Calculates $ \robabx{a}{c}{\mathbf{v}} = \robabx{a}{b}{\mathbf{R}} \robabx{b}{c}{\mathbf{v}} $. More...
 
template<class R >
 Rotation3D (const boost::numeric::ublas::matrix_expression< R > &r)
 Construct a rotation matrix from a Boost matrix expression. More...
 
template<class R >
 Rotation3D (const EigenMatrix3x3 &r)
 Construct a rotation matrix from a 3x3 Eigen matrix. More...
 
template<class R >
 Rotation3D (const Eigen::MatrixBase< R > &m)
 Construct a rotation matrix from a 3x3 Eigen matrix. More...
 
Rotation3D< T > & inverse ()
 Calculate the inverse. More...
 

Static Public Member Functions

static const Rotation3Didentity ()
 Constructs a 3x3 rotation matrix set to identity. More...
 
static void multiply (const Rotation3D< T > &a, const Rotation3D< T > &b, Rotation3D< T > &result)
 Write to result the product a * b.
 
static void multiply (const Rotation3D< T > &a, const Vector3D< T > &b, Vector3D< T > &result)
 Write to result the product a * b.
 
static const Rotation3D< T > multiply (const Rotation3D< T > &aRb, const Rotation3D< T > &bRc)
 Calculates $ \robabx{a}{c}{\mathbf{R}} = \robabx{a}{b}{\mathbf{R}} \robabx{b}{c}{\mathbf{R}} $. More...
 
static const Vector3D< T > multiply (const Rotation3D< T > &aRb, const Vector3D< T > &bVc)
 Calculates $ \robabx{a}{c}{\mathbf{v}} = \robabx{a}{b}{\mathbf{R}} \robabx{b}{c}{\mathbf{v}} $. More...
 

Related Functions

(Note that these are not member functions.)

static Rotation3D< T > skew (const Vector3D< T > &v)
 Creates a skew symmetric matrix from a Vector3D. Also known as the cross product matrix of v. More...
 
template<class Q , class T >
const Rotation3D< Qcast (const Rotation3D< T > &rot)
 Casts Rotation3D<T> to Rotation3D<Q> More...
 
template<class T >
const Rotation3D< T > inverse (const Rotation3D< T > &aRb)
 Calculates the inverse $ \robabx{b}{a}{\mathbf{R}} = \robabx{a}{b}{\mathbf{R}}^{-1} $ of a rotation matrix. More...
 
template<class T >
std::ostream & operator<< (std::ostream &os, const Rotation3D< T > &r)
 Writes rotation matrix to stream. More...
 
template<>
void write (const rw::math::Rotation3D< double > &sobject, rw::common::OutputArchive &oarchive, const std::string &id)
 
template<>
void write (const rw::math::Rotation3D< float > &sobject, rw::common::OutputArchive &oarchive, const std::string &id)
 
template<>
void read (rw::math::Rotation3D< double > &sobject, rw::common::InputArchive &iarchive, const std::string &id)
 
template<>
void read (rw::math::Rotation3D< float > &sobject, rw::common::InputArchive &iarchive, const std::string &id)
 

Detailed Description

template<class T = double>
class rw::math::Rotation3D< T >

A 3x3 rotation matrix $ \mathbf{R}\in SO(3) $.

$ \mathbf{R}= \left[ \begin{array}{ccc} {}^A\hat{X}_B & {}^A\hat{Y}_B & {}^A\hat{Z}_B \end{array} \right] = \left[ \begin{array}{ccc} r_{11} & r_{12} & r_{13} \\ r_{21} & r_{22} & r_{23} \\ r_{31} & r_{32} & r_{33} \end{array} \right] $

Constructor & Destructor Documentation

◆ Rotation3D() [1/5]

Rotation3D ( r11,
r12,
r13,
r21,
r22,
r23,
r31,
r32,
r33 
)
inline

Constructs an initialized 3x3 rotation matrix.

Parameters
r11$ r_{11} $
r12$ r_{12} $
r13$ r_{13} $
r21$ r_{21} $
r22$ r_{22} $
r23$ r_{23} $
r31$ r_{31} $
r32$ r_{32} $
r33$ r_{33} $

$ \mathbf{R} = \left[ \begin{array}{ccc} r_{11} & r_{12} & r_{13} \\ r_{21} & r_{22} & r_{23} \\ r_{31} & r_{32} & r_{33} \end{array} \right] $

◆ Rotation3D() [2/5]

Rotation3D ( const Vector3D< T > &  i,
const Vector3D< T > &  j,
const Vector3D< T > &  k 
)
inline

Constructs an initialized 3x3 rotation matrix $ \robabx{a}{b}{\mathbf{R}} = \left[ \begin{array}{ccc} \robabx{a}{b}{\mathbf{i}} & \robabx{a}{b}{\mathbf{j}} & \robabx{a}{b}{\mathbf{k}} \end{array} \right] $.

Parameters
i$ \robabx{a}{b}{\mathbf{i}} $
j$ \robabx{a}{b}{\mathbf{j}} $
k$ \robabx{a}{b}{\mathbf{k}} $

◆ Rotation3D() [3/5]

Rotation3D ( const boost::numeric::ublas::matrix_expression< R > &  r)
inlineexplicit

Construct a rotation matrix from a Boost matrix expression.

The matrix expression must be convertible to a 3x3 bounded matrix.

It is the responsibility of the user that 3x3 matrix is indeed a rotation matrix.

◆ Rotation3D() [4/5]

Rotation3D ( const EigenMatrix3x3 r)
inlineexplicit

Construct a rotation matrix from a 3x3 Eigen matrix.

It is the responsibility of the user that 3x3 matrix is indeed a rotation matrix.

◆ Rotation3D() [5/5]

Rotation3D ( const Eigen::MatrixBase< R > &  m)
inlineexplicit

Construct a rotation matrix from a 3x3 Eigen matrix.

It is the responsibility of the user that 3x3 matrix is indeed a rotation matrix.

Member Function Documentation

◆ e()

EigenMatrix3x3 e ( ) const

Returns a Eigen 3x3 matrix $ \mathbf{M}\in SO(3) $ that represents this rotation.

Returns
$ \mathbf{M}\in SO(3) $

◆ equal()

bool equal ( const Rotation3D< T > &  rot,
const T  precision = std::numeric_limits<T>::epsilon() 
) const
inline

Compares rotations with a given precision.

Performs an element wise comparison. Two elements are considered equal if the difference are less than precision.

Parameters
rot[in] Rotation to compare with
precision[in] The precision to use for testing
Returns
True if all elements are less than precision apart.

◆ getCol()

const Vector3D<T> getCol ( size_t  i) const
inline

Returns the i'th column of the rotation matrix.

Parameters
i[in] Index of the column to return. Only valid indices are 0, 1 and 2.

◆ getRow()

const Vector3D<T> getRow ( size_t  i) const
inline

Returns the i'th row of the rotation matrix.

Parameters
i[in] Index of the row to return. Only valid indices are 0, 1 and 2.

◆ identity()

static const Rotation3D& identity ( )
inlinestatic

Constructs a 3x3 rotation matrix set to identity.

Returns
a 3x3 identity rotation matrix

$ \mathbf{R} = \left[ \begin{array}{ccc} 1 & 0 & 0 \\ 0 & 1 & 0 \\ 0 & 0 & 1 \end{array} \right] $

◆ inverse()

Rotation3D<T>& inverse ( )
inline

Calculate the inverse.

Note
This function changes the object that it is invoked on, but this is about x5 faster than rot = inverse( rot )
See also
inverse(const Rotation3D< T > &) for the (slower) version that does not change the rotation object itself.
Returns
the inverse rotation.

◆ isProperRotation() [1/2]

bool isProperRotation ( ) const

Verify that this rotation is a proper rotation.

Returns
True if this rotation is considered a proper rotation

◆ isProperRotation() [2/2]

bool isProperRotation ( precision) const

Verify that this rotation is a proper rotation.

Returns
True if this rotation is considered a proper rotation

◆ m()

BoostMatrix3x3 m ( ) const

Returns a Boost 3x3 matrix $ \mathbf{M}\in SO(3) $ that represents this rotation.

Returns
$ \mathbf{M}\in SO(3) $

◆ multiply() [1/2]

static const Rotation3D<T> multiply ( const Rotation3D< T > &  aRb,
const Rotation3D< T > &  bRc 
)
static

Calculates $ \robabx{a}{c}{\mathbf{R}} = \robabx{a}{b}{\mathbf{R}} \robabx{b}{c}{\mathbf{R}} $.

Parameters
aRb[in] $ \robabx{a}{b}{\mathbf{R}} $
bRc[in] $ \robabx{b}{c}{\mathbf{R}} $
Returns
$ \robabx{a}{c}{\mathbf{R}} $

◆ multiply() [2/2]

static const Vector3D<T> multiply ( const Rotation3D< T > &  aRb,
const Vector3D< T > &  bVc 
)
static

Calculates $ \robabx{a}{c}{\mathbf{v}} = \robabx{a}{b}{\mathbf{R}} \robabx{b}{c}{\mathbf{v}} $.

Parameters
aRb[in] $ \robabx{a}{b}{\mathbf{R}} $
bVc[in] $ \robabx{b}{c}{\mathbf{v}} $
Returns
$ \robabx{a}{c}{\mathbf{v}} $

◆ normalize()

void normalize ( )

Normalizes the rotation matrix to satisfy SO(3).

Makes a normalization of the rotation matrix such that the columns are normalized and othogonal s.t. it belongs to SO(3).

◆ operator!=()

bool operator!= ( const Rotation3D< T > &  rhs) const
inline

Comparison operator.

The comparison operator makes a element wise comparison. Returns true if any of the elements are different.

Parameters
rhs[in] Rotation to compare with
Returns
True if not equal.

◆ operator()() [1/2]

T& operator() ( size_t  row,
size_t  column 
)
inline

Returns reference to matrix element.

Parameters
row[in] row
column[in] column
Returns
reference to the element

◆ operator()() [2/2]

const T& operator() ( size_t  row,
size_t  column 
) const
inline

Returns reference to matrix element.

Parameters
row[in] row
column[in] column
Returns
reference to the element

◆ operator*() [1/2]

const Rotation3D operator* ( const Rotation3D< T > &  bRc) const
inline

Calculates $ \robabx{a}{c}{\mathbf{R}} = \robabx{a}{b}{\mathbf{R}} \robabx{b}{c}{\mathbf{R}} $.

Parameters
bRc[in] $ \robabx{b}{c}{\mathbf{R}} $
Returns
$ \robabx{a}{c}{\mathbf{R}} $

◆ operator*() [2/2]

const Vector3D<T> operator* ( const Vector3D< T > &  bVc) const
inline

Calculates $ \robabx{a}{c}{\mathbf{v}} = \robabx{a}{b}{\mathbf{R}} \robabx{b}{c}{\mathbf{v}} $.

Parameters
bVc[in] $ \robabx{b}{c}{\mathbf{v}} $
Returns
$ \robabx{a}{c}{\mathbf{v}} $

◆ operator==()

bool operator== ( const Rotation3D< T > &  rhs) const
inline

Comparison operator.

The comparison operator makes a element wise comparison. Returns true only if all elements are equal.

Parameters
rhs[in] Rotation to compare with
Returns
True if equal.

Friends And Related Function Documentation

◆ read() [1/2]

void read ( rw::math::Rotation3D< double > &  sobject,
rw::common::InputArchive iarchive,
const std::string &  id 
)
related

Enable read-serialization of class T by overloading this method. Data is read from iarchive and filled into sobject.

Parameters
sobject[out] the object in which the data should be streamed into
iarchive[in] the InputArchive from which to read data.
id[in] The id of the serialized sobject.
Note
the id can be empty in which case the overloaded method should provide a default identifier. E.g. the Vector3D class defined "Vector3D" as its default id.

◆ read() [2/2]

void read ( rw::math::Rotation3D< float > &  sobject,
rw::common::InputArchive iarchive,
const std::string &  id 
)
related

Enable read-serialization of class T by overloading this method. Data is read from iarchive and filled into sobject.

Parameters
sobject[out] the object in which the data should be streamed into
iarchive[in] the InputArchive from which to read data.
id[in] The id of the serialized sobject.
Note
the id can be empty in which case the overloaded method should provide a default identifier. E.g. the Vector3D class defined "Vector3D" as its default id.

◆ skew()

static Rotation3D<T> skew ( const Vector3D< T > &  v)
related

Creates a skew symmetric matrix from a Vector3D. Also known as the cross product matrix of v.

Parameters
v[in] vector to create Skew matrix from

◆ write() [1/2]

void write ( const rw::math::Rotation3D< double > &  sobject,
rw::common::OutputArchive oarchive,
const std::string &  id 
)
related

Enable write-serialization of class T by overloading this method. Data is written to oarchive from the sobject.

Parameters
sobject[in] the object from which the data should be streamed.
oarchive[out] the OutputArchive in which data should be written.
id[in] The id of the serialized sobject.
Note
the id can be empty in which case the overloaded method should provide a default identifier. E.g. the Vector3D class defined "Vector3D" as its default id.

◆ write() [2/2]

void write ( const rw::math::Rotation3D< float > &  sobject,
rw::common::OutputArchive oarchive,
const std::string &  id 
)
related

Enable write-serialization of class T by overloading this method. Data is written to oarchive from the sobject.

Parameters
sobject[in] the object from which the data should be streamed.
oarchive[out] the OutputArchive in which data should be written.
id[in] The id of the serialized sobject.
Note
the id can be empty in which case the overloaded method should provide a default identifier. E.g. the Vector3D class defined "Vector3D" as its default id.

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