RobWorkProject  24.8.23-
Public Types | Public Member Functions | Static Public Member Functions | Friends | 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 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 rw::math::Vector3D< T > &i, const rw::math::Vector3D< T > &j, const rw::math::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...
 
 Rotation3D (const Rotation3DVector< T > &rotVec)
 Initialize Rotation3D from other rotation types. 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 rw::math::Vector3D< T > getRow (size_t i) const
 Returns the i'th row of the rotation matrix. More...
 
const rw::math::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...
 
const EigenMatrix3x3e () const
 Returns a Eigen 3x3 matrix \( \mathbf{M}\in SO(3) \) that represents this rotation. More...
 
EigenMatrix3x3e ()
 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...
 
template<class R >
const Rotation3D operator* (const Eigen::MatrixBase< R > &rhs) const
 Calculates \( \robabx{a}{c}{\mathbf{R}} = \robabx{a}{b}{\mathbf{R}} \robabx{b}{c}{\mathbf{R}} \). More...
 
const rw::math::Vector3D< T > operator* (const rw::math::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 EigenMatrix3x3 &r)
 Construct a rotation matrix from a 3x3 Eigen matrix It is the responsibility of the user that 3x3 matrix is indeed a rotation matrix.
 
template<class R >
 Rotation3D (const Eigen::MatrixBase< R > &m)
 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< T > & inverse ()
 Calculate the inverse. More...
 
Rotation3D< T > inverse (bool copy)
 Calculate the inverse. More...
 
const Rotation3D< T > inverse (bool copy) const
 Calculate the inverse. of a const Rotation3D. For this function copy is always true. More...
 
tr () const
 
Rotation3D< T > & operator= (const Rotation3DVector< T > &rot)
 Assignment of RotationVector to Rotation3D. More...
 

Static Public Member Functions

static const Rotation3D< T > identity ()
 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 rw::math::Vector3D< T > &b, rw::math::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 rw::math::Vector3D< T > multiply (const Rotation3D< T > &aRb, const rw::math::Vector3D< T > &bVc)
 Calculates \( \robabx{a}{c}{\mathbf{v}} = \robabx{a}{b}{\mathbf{R}} \robabx{b}{c}{\mathbf{v}} \). More...
 

Friends

template<class R >
Rotation3D operator* (const Eigen::MatrixBase< R > &lhs, const Rotation3D< T > &rhs)
 Calculates \( \robabx{a}{c}{\mathbf{R}} = \robabx{a}{b}{\mathbf{R}} \robabx{b}{c}{\mathbf{R}} \). More...
 

Related Functions

(Note that these are not member functions.)

static Rotation3D< T > skew (const rw::math::Vector3D< T > &v)
 Creates a skew symmetric matrix from a Vector3D. Also known as the cross product matrix of v. More...
 
template<class S , class T >
const Rotation3D< S > cast (const Rotation3D< T > &rot)
 Casts Rotation3D<T> to Rotation3D More...
 
template<class T >
const rw::math::Rotation3D< T > inverse (const rw::math::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)
 
template<class Archive , class T >
void serialize (Archive &archive, rw::math::Rotation3D< T > &R, const unsigned int version)
 Boost serialization. More...
 

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/3]

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/3]

Rotation3D ( const rw::math::Vector3D< T > &  i,
const rw::math::Vector3D< T > &  j,
const rw::math::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/3]

Rotation3D ( const Rotation3DVector< T > &  rotVec)
explicit

Initialize Rotation3D from other rotation types.

Parameters
rotVec[in] rotation type such as EAA, RPY, or Quaternion

Member Function Documentation

◆ e() [1/2]

EigenMatrix3x3& e ( )
inline

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

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

◆ e() [2/2]

const EigenMatrix3x3& e ( ) const
inline

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 rw::math::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 rw::math::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<T> 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() [1/3]

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
rw::math::inverse(const rw::math::Rotation3D< T > &) for the (slower) version that does not change the rotation object itself.
Returns
the inverse rotation.

◆ inverse() [2/3]

Rotation3D<T> inverse ( bool  copy)

Calculate the inverse.

Parameters
copy[in] if coopy is false, This function changes the object that it is invoked on, but this is about x5 faster than rot = inverse( rot ). else it changes the object, making it a bit slower.
Returns
the inverse rotation.

◆ inverse() [3/3]

const Rotation3D<T> inverse ( bool  copy) const

Calculate the inverse. of a const Rotation3D. For this function copy is always true.

Parameters
copy[in] always true
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

◆ 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 rw::math::Vector3D<T> multiply ( const Rotation3D< T > &  aRb,
const rw::math::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/3]

const Rotation3D operator* ( const Eigen::MatrixBase< R > &  rhs) const
inline

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

Parameters
rhs[in] \( \robabx{b}{c}{\mathbf{R}} \)
Returns
\( \robabx{a}{c}{\mathbf{R}} \)

◆ operator*() [2/3]

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*() [3/3]

const rw::math::Vector3D<T> operator* ( const rw::math::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=()

Rotation3D<T>& operator= ( const Rotation3DVector< T > &  rot)

Assignment of RotationVector to Rotation3D.

Parameters
rot[in] Rotation input

◆ 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

◆ cast()

const Rotation3D< S > cast ( const Rotation3D< T > &  rot)
related

Casts Rotation3D<T> to Rotation3D

Parameters
rot[in] Rotation3D with type T
Returns
Rotation3D with type S

◆ inverse()

const rw::math::Rotation3D< T > inverse ( const rw::math::Rotation3D< T > &  aRb)
related

Calculates the inverse \( \robabx{b}{a}{\mathbf{R}} = \robabx{a}{b}{\mathbf{R}}^{-1} \) of a rotation matrix.

See also
Rotation3D::inverse() for a faster version that modifies the existing rotation object instead of allocating a new one.
Parameters
aRb[in] the rotation matrix \( \robabx{a}{b}{\mathbf{R}} \)
Returns
the matrix inverse \( \robabx{b}{a}{\mathbf{R}} = \robabx{a}{b}{\mathbf{R}}^{-1} \)

\( \robabx{b}{a}{\mathbf{R}} = \robabx{a}{b}{\mathbf{R}}^{-1} = \robabx{a}{b}{\mathbf{R}}^T \)

◆ operator*

Rotation3D operator* ( const Eigen::MatrixBase< R > &  lhs,
const Rotation3D< T > &  rhs 
)
friend

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

Parameters
lhs[in] \( \robabx{b}{c}{\mathbf{R}} \)
rhs[in] \( \robabx{b}{c}{\mathbf{R}} \)
Returns
\( \robabx{a}{c}{\mathbf{R}} \)

◆ operator<<()

std::ostream & operator<< ( std::ostream &  os,
const Rotation3D< T > &  r 
)
related

Writes rotation matrix to stream.

Parameters
os[in/out] output stream to use
r[in] rotation matrix to print
Returns
the updated output stream

◆ 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.

◆ serialize()

void serialize ( Archive &  archive,
rw::math::Rotation3D< T > &  R,
const unsigned int  version 
)
related

Boost serialization.

Parameters
archive[in] the boost archive to read from or write to.
R[in/out] the rotation matrix to read/write.
version[in] class version (currently version 0).

◆ skew()

static Rotation3D<T> skew ( const rw::math::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 files: