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

A 4x4 homogeneous transform matrix $ \mathbf{T}\in SE(3) $. More...

#include <Transform3D.hpp>

Public Types

typedef T value_type
 Value type.
 
typedef Eigen::Matrix< T, 4, 4 > EigenMatrix4x4
 Type for the internal Eigen matrix.
 

Public Member Functions

 Transform3D ()
 Default Constructor. More...
 
 Transform3D (const Vector3D< T > &d, const Rotation3D< T > &R)
 Constructs a homogeneous transform. More...
 
 Transform3D (const Rotation3D< T > &R)
 A homogeneous transform with a rotation of R and a translation of zero.
 
 Transform3D (const Vector3D< T > &d)
 A homogeneous transform with a rotation of zero and a translation of d.
 
 Transform3D (const Vector3D< T > &d, const Rotation3DVector< T > &r)
 Constructs a homogeneous transform. More...
 
T & operator() (std::size_t row, std::size_t col)
 Returns matrix element reference. More...
 
const T & operator() (std::size_t row, std::size_t col) const
 Returns const matrix element reference. More...
 
bool operator== (const Transform3D< T > &rhs) const
 Comparison operator. More...
 
bool operator!= (const Transform3D< T > &rhs) const
 Comparison operator. More...
 
bool equal (const Transform3D< T > &t3d, const T precision=std::numeric_limits< T >::epsilon()) const
 Compares the transformations with a given precision. More...
 
const Transform3D operator* (const Transform3D &bTc) const
 Calculates $ \robabx{a}{c}{\mathbf{T}} = \robabx{a}{b}{\mathbf{T}} \robabx{b}{c}{\mathbf{T}} $. More...
 
const Vector3D< T > operator* (const Vector3D< T > &bP) const
 Calculates $ \robax{a}{\mathbf{p}} = \robabx{a}{b}{\mathbf{T}} \robax{b}{\mathbf{p}} $ thus transforming point $ \mathbf{p} $ from frame $ b $ to frame $ a $. More...
 
Rotation3D< T > & R ()
 Gets the rotation part $ \mathbf{R} $ from $ \mathbf{T} $. More...
 
const Rotation3D< T > & R () const
 Gets the rotation part $ \mathbf{R} $ from $ \mathbf{T} $. More...
 
Vector3D< T > & P ()
 Gets the position part $ \mathbf{d} $ from $ \mathbf{T} $. More...
 
const Vector3D< T > & P () const
 Gets the position part $ \mathbf{d} $ from $ \mathbf{T} $. More...
 
EigenMatrix4x4 e () const
 Returns a Eigen 4x4 matrix $ \mathbf{M}\in SE(3) $ that represents this homogeneous transformation. More...
 

Static Public Member Functions

static const Transform3D DH (T alpha, T a, T d, T theta)
 Constructs a homogeneous transform using the original Denavit-Hartenberg notation. More...
 
static const Transform3D craigDH (T alpha, T a, T d, T theta)
 Constructs a homogeneous transform using the Craig (modified) Denavit-Hartenberg notation. More...
 
static const Transform3D DHHGP (T alpha, T a, T beta, T b)
 Constructs a homogeneous transform using the Gordon (modified) Denavit-Hartenberg notation. More...
 
static const Transform3Didentity ()
 Constructs the identity transform. More...
 
static void multiply (const Transform3D< T > &a, const Transform3D< T > &b, Transform3D< T > &result)
 Write to result the product a * b.
 
static Transform3D< T > & invMult (Transform3D< T > &t1, const Transform3D< T > &t2)
 computes the inverse of t1 and multiplies it with t2. The result is saved in t1. t1 = inv(t1) * t2
 
static Transform3D< T > & invMult (const Transform3D< T > &t1, const Transform3D< T > &t2, Transform3D< T > &t3)
 computes the inverse of t1 and multiplies it with t2. The result is saved in t1. t1 = inv(t1) * t2
 
static Transform3D< T > makeLookAt (const Vector3D< T > &eye, const Vector3D< T > &center, const Vector3D< T > &up)
 creates a transformation that is positioned in eye and looking toward center along -z where up indicates the upward direction along which the y-axis is placed. Same convention as for gluLookAt and is handy for placing a cameraview. More...
 

Friends

std::ostream & operator<< (std::ostream &os, const Transform3D< T > &t)
 Outputs transform to stream. More...
 

Related Functions

(Note that these are not member functions.)

template<class T >
const Transform3D< T > inverse (const Transform3D< T > &aTb)
 Calculates $ \robabx{b}{a}{\mathbf{T}} = \robabx{a}{b}{\mathbf{T}}^{-1} $. More...
 
template<>
void write (const rw::math::Transform3D< double > &sobject, rw::common::OutputArchive &oarchive, const std::string &id)
 
template<>
void write (const rw::math::Transform3D< float > &sobject, rw::common::OutputArchive &oarchive, const std::string &id)
 
template<>
void read (rw::math::Transform3D< double > &sobject, rw::common::InputArchive &iarchive, const std::string &id)
 
template<>
void read (rw::math::Transform3D< float > &sobject, rw::common::InputArchive &iarchive, const std::string &id)
 

Detailed Description

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

A 4x4 homogeneous transform matrix $ \mathbf{T}\in SE(3) $.

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

Constructor & Destructor Documentation

◆ Transform3D() [1/3]

Transform3D ( )
inline

Default Constructor.

Initializes with 0 translation and Identity matrix as rotation

◆ Transform3D() [2/3]

Transform3D ( const Vector3D< T > &  d,
const Rotation3D< T > &  R 
)
inline

Constructs a homogeneous transform.

Parameters
d[in] $ \mathbf{d} $ A 3x1 translation vector
R[in] $ \mathbf{R} $ A 3x3 rotation matrix

◆ Transform3D() [3/3]

Transform3D ( const Vector3D< T > &  d,
const Rotation3DVector< T > &  r 
)
inline

Constructs a homogeneous transform.

Calling this constructor is equivalent to the transform Transform3D(d, r.toRotation3D()).

Parameters
d[in] $ \mathbf{d} $ A 3x1 translation vector
r[in] $ \mathbf{r} $ A 3x1 rotation vector

Member Function Documentation

◆ craigDH()

static const Transform3D craigDH ( alpha,
a,
d,
theta 
)
static

Constructs a homogeneous transform using the Craig (modified) Denavit-Hartenberg notation.

Parameters
alpha[in] $ \alpha_{i-1} $
a[in] $ a_{i-1} $
d[in] $ d_i $
theta[in] $ \theta_i $
Returns
$ \robabx{i-1}{i}{\mathbf{T}} $
Note
The Craig (modified) Denavit-Hartenberg notation differs from the original Denavit-Hartenberg notation and is given as

$ \robabx{i-1}{i}{\mathbf{T}} = \left[ \begin{array}{cccc} c\theta_i & -s\theta_i & 0 & a_{i-1} \\ s\theta_i c\alpha_{i-1} & c\theta_i c\alpha_{i-1} & -s\alpha_{i-1} & -s\alpha_{i-1}d_i \\ s\theta_i s\alpha_{i-1} & c\theta_i s\alpha_{i-1} & c\alpha_{i-1} & c\alpha_{i-1}d_i \\ 0 & 0 & 0 & 1 \end{array} \right] $

◆ DH()

static const Transform3D DH ( alpha,
a,
d,
theta 
)
static

Constructs a homogeneous transform using the original Denavit-Hartenberg notation.

Parameters
alpha[in] $ \alpha_i $
a[in] $ a_i $
d[in] $ d_i $
theta[in] $ \theta_i $
Returns
$ ^{i-1}\mathbf{T}_i $

$ \robabx{i-1}{i}{\mathbf{T}}= \left[ \begin{array}{cccc} c\theta_i & -s\theta_i c\alpha_i & s\theta_i s\alpha_i & a_i c\theta_i \\ s\theta_i & c\theta_i c\alpha_i & -c\theta_i s\alpha_i & a_i s\theta_i \\ 0 & s\alpha_i & c\alpha_i & d_i \\ 0 & 0 & 0 & 1 \end{array} \right] $

◆ DHHGP()

static const Transform3D DHHGP ( alpha,
a,
beta,
b 
)
static

Constructs a homogeneous transform using the Gordon (modified) Denavit-Hartenberg notation.

Parameters
alpha[in] $ \alpha_i $
a[in] $ a_i $
beta[in] $ \beta_i $
b[in] $ b_i $
Returns
$ ^{i-1}\mathbf{T}_i $
Note
The Gordon (modified) Denavit-Hartenberg differs from the original Denavit-Hartenberg as it branches between parallel and non-parallel z-axes.

$ z_{i-1} $ is close to parallel to $ z_i $ $ \robabx{i-1}{i}{\mathbf{T}}= \left[ \begin{array}{cccc} c\beta_i & s\alpha_i s\beta_i & c\alpha_i s\beta_i & a_i c\beta_i \\ 0 & c\alpha_i & -s\alpha_i & b_i \\ -s\beta_i & s\alpha_i c\beta_i & c\alpha_i c\beta_i & -a_i s\beta \\ 0 & 0 & 0 & 1 \end{array} \right] $

◆ e()

EigenMatrix4x4 e ( ) const

Returns a Eigen 4x4 matrix $ \mathbf{M}\in SE(3) $ that represents this homogeneous transformation.

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

◆ equal()

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

Compares the transformations with a given precision.

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

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

◆ identity()

static const Transform3D& identity ( )
inlinestatic

Constructs the identity transform.

Returns
the identity transform

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

◆ makeLookAt()

static Transform3D<T> makeLookAt ( const Vector3D< T > &  eye,
const Vector3D< T > &  center,
const Vector3D< T > &  up 
)
inlinestatic

creates a transformation that is positioned in eye and looking toward center along -z where up indicates the upward direction along which the y-axis is placed. Same convention as for gluLookAt and is handy for placing a cameraview.

Parameters
eye[in] position of view
center[in] point to look toward
up[in] the upward direction (the
Returns
Transformation

◆ operator!=()

bool operator!= ( const Transform3D< 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] Transform to compare with
Returns
True if not equal.

◆ operator()() [1/2]

T& operator() ( std::size_t  row,
std::size_t  col 
)
inline

Returns matrix element reference.

Parameters
row[in] row, row must be $ < 3 $
col[in] col, col must be $ < 4 $
Returns
reference to matrix element

◆ operator()() [2/2]

const T& operator() ( std::size_t  row,
std::size_t  col 
) const
inline

Returns const matrix element reference.

Parameters
row[in] row, row must be $ < 3 $
col[in] col, col must be $ < 4 $
Returns
const reference to matrix element

◆ operator*() [1/2]

const Transform3D operator* ( const Transform3D< T > &  bTc) const
inline

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

Parameters
bTc[in] $ \robabx{b}{c}{\mathbf{T}} $
Returns
$ \robabx{a}{c}{\mathbf{T}} $

$ \robabx{a}{c}{\mathbf{T}} = \left[ \begin{array}{cc} \robabx{a}{b}{\mathbf{R}}\robabx{b}{c}{\mathbf{R}} & \robabx{a}{b}{\mathbf{d}} + \robabx{a}{b}{\mathbf{R}}\robabx{b}{c}{\mathbf{d}} \\ \begin{array}{ccc}0 & 0 & 0\end{array} & 1 \end{array} \right] $

◆ operator*() [2/2]

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

Calculates $ \robax{a}{\mathbf{p}} = \robabx{a}{b}{\mathbf{T}} \robax{b}{\mathbf{p}} $ thus transforming point $ \mathbf{p} $ from frame $ b $ to frame $ a $.

Parameters
bP[in] $ \robax{b}{\mathbf{p}} $
Returns
$ \robax{a}{\mathbf{p}} $

◆ operator==()

bool operator== ( const Transform3D< 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] Transform to compare with
Returns
True if equal.

◆ P() [1/2]

Vector3D<T>& P ( )
inline

Gets the position part $ \mathbf{d} $ from $ \mathbf{T} $.

Returns
$ \mathbf{d} $

◆ P() [2/2]

const Vector3D<T>& P ( ) const
inline

Gets the position part $ \mathbf{d} $ from $ \mathbf{T} $.

Returns
$ \mathbf{d} $

◆ R() [1/2]

Rotation3D<T>& R ( )
inline

Gets the rotation part $ \mathbf{R} $ from $ \mathbf{T} $.

Returns
$ \mathbf{R} $

◆ R() [2/2]

const Rotation3D<T>& R ( ) const
inline

Gets the rotation part $ \mathbf{R} $ from $ \mathbf{T} $.

Returns
$ \mathbf{R} $

Friends And Related Function Documentation

◆ operator<<

std::ostream& operator<< ( std::ostream &  os,
const Transform3D< T > &  t 
)
friend

Outputs transform to stream.

Parameters
os[in/out] an output stream
t[in] the transform that is to be sent to the output stream
Returns
os

◆ read() [1/2]

void read ( rw::math::Transform3D< 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::Transform3D< 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.

◆ write() [1/2]

void write ( const rw::math::Transform3D< 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::Transform3D< 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: