SOFA API  1a4bb3e7
Open source framework for multi-physics simuation
sofa::type::Transform< TReal > Class Template Reference

#include <Transform.h>

Detailed Description

template<class TReal>
class sofa::type::Transform< TReal >

Define a frame (child) whith respect to another (parent). A frame represents a local coordinate system.

Internal data represents the orientation of the child wrt the parent, BUT the translation vector represents the origin of the parent with respect to the child. For example, the coordinates M_p of point M in parent given the coordinates M_c of the same point in child are given by: M_p = orientation * ( M_c - origin ). This is due to Featherstone's conventions. Use method setTranslationRotation( const Vec& t, const Rot& q ) to model the Transform the standard way (i.e. translation givne in the parent frame).

Protected Attributes

Rot orientation_
 child wrt parent More...
 
Vec origin_
 parent wrt child More...
 

Public Member Functions

 Transform ()
 The default constructor does not initialize the transform. More...
 
 Transform (const Vec &origin, const Rot &orientation)
 Origin of the child in parent coordinates, orientation of the child wrt to parent. More...
 
 Transform (const Rot &q, const Vec &o)
 WARNING: using Featherstone's conventions (see class documentation) More...
 
void set (const Vec &t, const Rot &q)
 Origin of the child in the parent coordinate system and the orientation of the child wrt the parent (i.e. standard way) More...
 
void clear ()
 Reset this to identity. More...
 
 Transform (const SpatialVector< TReal > &v)
 Origin of the child in the parent coordinate system and the orientation of the child wrt the parent (i.e. standard way) More...
 
Transform inversed () const
 The inverse transform i.e. parent wrt child. More...
 
const VecgetOriginOfParentInChild () const
 Parent origin in child coordinates (the way it is actually stored internally) More...
 
Vec getOrigin () const
 Origin of child in parent coordinates. More...
 
void setOrigin (const Vec &)
 Origin of child in parent coordinates. More...
 
const RotgetOrientation () const
 Orientation of the child coordinate axes wrt the parent coordinate axes. More...
 
void setOrientation (const Rot &)
 Orientation of the child coordinate axes wrt the parent coordinate axes. More...
 
Mat3x3 getRotationMatrix () const
 Matrix which projects vectors from child coordinates to parent coordinates. The columns of the matrix are the axes of the child base axes in the parent coordinate system. More...
 
Mat6x6 getAdjointMatrix () const
 Adjoint matrix to the transform This matrix transports velocities in twist coordinates from the child frame to the parent frame. Its inverse transpose does the same for the wrenches. More...
 
Vec projectVector (const Vec &vectorInChild) const
 Project a vector (i.e. a direction or a displacement) from child coordinates to parent coordinates. More...
 
Vec projectPoint (const Vec &pointInChild) const
 Project a point from child coordinates to parent coordinates. More...
 
Vec backProjectVector (const Vec &vectorInParent) const
 Projected a vector (i.e. a direction or a displacement) from parent coordinates to child coordinates. More...
 
Vec backProjectPoint (const Vec &pointInParent) const
 Project point from parent coordinates to this coordinates. More...
 
Transform operator* (const Transform &f2) const
 Combine two transforms. If (*this) locates frame B (child) wrt frame A (parent) and if f2 locates frame C (child) wrt frame B (parent) then the result locates frame C wrt to Frame A. More...
 
Transformoperator*= (const Transform &f2)
 Combine two transforms. If (*this) locates frame B (child) wrt frame A (parent) and if f2 locates frame C (child) wrt frame B (parent) then the result locates frame C wrt to Frame A. More...
 
SpatialVector< TReal > CreateSpatialVector ()
 
SpatialVector< TReal > DTrans ()
 
SpatialVector< TReal > operator* (const SpatialVector< TReal > &sv) const
 
SpatialVector< TReal > operator/ (const SpatialVector< TReal > &sv) const
 Project a spatial vector from parent to child (the inverse of operator *). This method computes (*this).inversed()*sv without inverting (*this). More...
 
void writeOpenGlMatrix (double *m) const
 Write an OpenGL matrix encoding the transformation of the coordinate system of the child wrt the coordinate system of the parent. More...
 
void printInternal (std::ostream &) const
 Print the internal values (i.e. using Featherstone's conventions, see class documentation) More...
 
Time integration

Methods used in time integration

Transformoperator+= (const SpatialVector< TReal > &a)
 
Transformoperator+= (const Transform &a)
 
template<class Real2 >
Transformoperator*= (Real2 a)
 
template<class Real2 >
Transform operator* (Real2 a) const
 

Static Public Member Functions

static Transform identity ()
 The identity transform (child = parent) More...
 

Friends

std::ostream & operator<< (std::ostream &out, const Transform &t)
 
std::istream & operator>> (std::istream &in, Transform &t)
 read from an input stream More...
 

Attribute details

◆ orientation_

template<class TReal >
Rot sofa::type::Transform< TReal >::orientation_
protected

child wrt parent

◆ origin_

template<class TReal >
Vec sofa::type::Transform< TReal >::origin_
protected

parent wrt child

Constructor details

◆ Transform() [1/4]

template<class TReal >
sofa::type::Transform< TReal >::Transform

The default constructor does not initialize the transform.

◆ Transform() [2/4]

template<class TReal >
sofa::type::Transform< TReal >::Transform ( const Vec origin,
const Rot orientation 
)

Origin of the child in parent coordinates, orientation of the child wrt to parent.

Define using standard conventions.

◆ Transform() [3/4]

template<class TReal >
sofa::type::Transform< TReal >::Transform ( const Rot q,
const Vec o 
)

WARNING: using Featherstone's conventions (see class documentation)

Define using Featherstone's conventions.

◆ Transform() [4/4]

template<class TReal >
sofa::type::Transform< TReal >::Transform ( const SpatialVector< TReal > &  v)

Origin of the child in the parent coordinate system and the orientation of the child wrt the parent (i.e. standard way)

Define as a given SpatialVector integrated during one second. The spatial vector is given in parent coordinates.

Define child as a given SpatialVector<TReal> integrated during one second, starting from the parent (used for time integration). The spatial vector is given in parent coordinates.

Function details

◆ backProjectPoint()

template<class TReal >
auto sofa::type::Transform< TReal >::backProjectPoint ( const Vec pointInParent) const

Project point from parent coordinates to this coordinates.

◆ backProjectVector()

template<class TReal >
auto sofa::type::Transform< TReal >::backProjectVector ( const Vec vectorInParent) const

Projected a vector (i.e. a direction or a displacement) from parent coordinates to child coordinates.

◆ clear()

template<class TReal >
void sofa::type::Transform< TReal >::clear

Reset this to identity.

◆ CreateSpatialVector()

template<class TReal >
SpatialVector< TReal > sofa::type::Transform< TReal >::CreateSpatialVector

Project a spatial vector from child to parent TODO One should handle differently the transformation of a twist and a wrench ! This applying the adjoint to velocities or its transpose to wrench : V_parent = Ad . V_child or W_child = Ad^T . W_parent To project a wrench in the child frame to the parent frame you need to do parent_wrench = this->inversed * child_wrench (this doc needs to be douv-ble checked !)

◆ DTrans()

template<class TReal >
SpatialVector< TReal > sofa::type::Transform< TReal >::DTrans

◆ getAdjointMatrix()

template<class TReal >
auto sofa::type::Transform< TReal >::getAdjointMatrix

Adjoint matrix to the transform This matrix transports velocities in twist coordinates from the child frame to the parent frame. Its inverse transpose does the same for the wrenches.

◆ getOrientation()

template<class TReal >
const Transform< TReal >::Rot & sofa::type::Transform< TReal >::getOrientation

Orientation of the child coordinate axes wrt the parent coordinate axes.

◆ getOrigin()

template<class TReal >
Transform< TReal >::Vec sofa::type::Transform< TReal >::getOrigin

Origin of child in parent coordinates.

◆ getOriginOfParentInChild()

template<class TReal >
const Transform< TReal >::Vec & sofa::type::Transform< TReal >::getOriginOfParentInChild

Parent origin in child coordinates (the way it is actually stored internally)

◆ getRotationMatrix()

template<class TReal >
auto sofa::type::Transform< TReal >::getRotationMatrix

Matrix which projects vectors from child coordinates to parent coordinates. The columns of the matrix are the axes of the child base axes in the parent coordinate system.

◆ identity()

template<class TReal >
Transform< TReal > sofa::type::Transform< TReal >::identity
static

The identity transform (child = parent)

Define given the origin of the child wrt the parent and the orientation of the child wrt the parent (i.e. standard way)

◆ inversed()

template<class TReal >
Transform< TReal > sofa::type::Transform< TReal >::inversed

The inverse transform i.e. parent wrt child.

◆ operator*() [1/3]

template<class TReal >
SpatialVector< TReal > sofa::type::Transform< TReal >::operator* ( const SpatialVector< TReal > &  sv) const

◆ operator*() [2/3]

template<class TReal >
Transform< TReal > sofa::type::Transform< TReal >::operator* ( const Transform< TReal > &  f2) const

Combine two transforms. If (*this) locates frame B (child) wrt frame A (parent) and if f2 locates frame C (child) wrt frame B (parent) then the result locates frame C wrt to Frame A.

◆ operator*() [3/3]

template<class TReal >
template<class Real2 >
Transform sofa::type::Transform< TReal >::operator* ( Real2  a) const
inline

◆ operator*=() [1/2]

template<class TReal >
Transform< TReal > & sofa::type::Transform< TReal >::operator*= ( const Transform< TReal > &  f2)

Combine two transforms. If (*this) locates frame B (child) wrt frame A (parent) and if f2 locates frame C (child) wrt frame B (parent) then the result locates frame C wrt to Frame A.

◆ operator*=() [2/2]

template<class TReal >
template<class Real2 >
Transform& sofa::type::Transform< TReal >::operator*= ( Real2  a)
inline

◆ operator+=() [1/2]

template<class TReal >
Transform< TReal > & sofa::type::Transform< TReal >::operator+= ( const SpatialVector< TReal > &  a)

(this) *= Transform(v) Used for time integration. SHOULD WE RATHER APPLY (*this)=Transform(v)(*this) ???

◆ operator+=() [2/2]

template<class TReal >
Transform< TReal > & sofa::type::Transform< TReal >::operator+= ( const Transform< TReal > &  a)

◆ operator/()

template<class TReal >
SpatialVector< TReal > sofa::type::Transform< TReal >::operator/ ( const SpatialVector< TReal > &  sv) const

Project a spatial vector from parent to child (the inverse of operator *). This method computes (*this).inversed()*sv without inverting (*this).

◆ printInternal()

template<class TReal >
void sofa::type::Transform< TReal >::printInternal ( std::ostream &  out) const

Print the internal values (i.e. using Featherstone's conventions, see class documentation)

◆ projectPoint()

template<class TReal >
auto sofa::type::Transform< TReal >::projectPoint ( const Vec pointInChild) const

Project a point from child coordinates to parent coordinates.

◆ projectVector()

template<class TReal >
Transform< TReal >::Vec sofa::type::Transform< TReal >::projectVector ( const Vec vectorInChild) const

Project a vector (i.e. a direction or a displacement) from child coordinates to parent coordinates.

◆ set()

template<class TReal >
void sofa::type::Transform< TReal >::set ( const Vec t,
const Rot q 
)

Origin of the child in the parent coordinate system and the orientation of the child wrt the parent (i.e. standard way)

Define given the origin of the child wrt the parent and the orientation of the child wrt the parent (i.e. standard way)

◆ setOrientation()

template<class TReal >
void sofa::type::Transform< TReal >::setOrientation ( const Rot q)

Orientation of the child coordinate axes wrt the parent coordinate axes.

◆ setOrigin()

template<class TReal >
void sofa::type::Transform< TReal >::setOrigin ( const Vec op)

Origin of child in parent coordinates.

◆ writeOpenGlMatrix()

template<class TReal >
void sofa::type::Transform< TReal >::writeOpenGlMatrix ( double *  m) const

Write an OpenGL matrix encoding the transformation of the coordinate system of the child wrt the coordinate system of the parent.

Related details

◆ operator<<

template<class TReal >
std::ostream& operator<< ( std::ostream &  out,
const Transform< TReal > &  t 
)
friend

Draw the axes of the child coordinate system in the parent coordinate system Print the origin of the child in the parent coordinate system and the quaternion defining the orientation of the child wrt the parent

◆ operator>>

template<class TReal >
std::istream& operator>> ( std::istream &  in,
Transform< TReal > &  t 
)
friend

read from an input stream