chrono::ChFrame< Real > Class Template Reference

Description

template<class Real = double>
class chrono::ChFrame< Real >

ChFrame: a class for coordinate systems in 3D space.

A 'frame' coordinate system has a translation and a rotation respect to a 'parent' coordinate system, usually the absolute (world) coordinates.

Differently from a simple ChCoordsys object, however, the ChFrame implements some optimizations because each ChFrame stores also a 3x3 rotation matrix, which can speed up coordinate transformations when a large amount of vectors must be transformed by the same coordinate frame.

Further info at the Coordinate transformations manual page.

#include <ChFrame.h>

Inheritance diagram for chrono::ChFrame< Real >:

Public Member Functions

 ChFrame (const ChVector< Real > &mv=ChVector< Real >(0, 0, 0), const ChQuaternion< Real > &mq=ChQuaternion< Real >(1, 0, 0, 0))
 Default constructor, or construct from pos and rot (as a quaternion)
 
 ChFrame (const ChVector< Real > &mv, const ChMatrix33< Real > &ma)
 Construct from pos and rotation (as a 3x3 matrix)
 
 ChFrame (const ChCoordsys< Real > &mc)
 Construct from a coordsys.
 
 ChFrame (const ChVector< Real > &mv, const Real alpha, const ChVector< Real > &mu)
 Construct from position mv and rotation of angle alpha around unit vector mu.
 
 ChFrame (const ChFrame< Real > &other)
 Copy constructor, build from another frame.
 
ChFrame< Real > & operator= (const ChFrame< Real > &other)
 Assignment operator: copy from another frame.
 
virtual bool operator== (const ChFrame< Real > &other) const
 Returns true for identical frames.
 
virtual bool operator!= (const ChFrame< Real > &other) const
 Returns true for different frames.
 
ChFrame< Real > operator>> (const ChFrame< Real > &Fb) const
 The '>>' operator transforms a coordinate system, so transformations can be represented with this syntax: new_frame = old_frame >> tr_frame; For a sequence of transformations, i.e. More...
 
ChFrame< Real > operator* (const ChFrame< Real > &Fb) const
 The '>>' operator transforms a vector, so transformations can be represented with this syntax: new_v = old_v >> tr_frame; For a sequence of transformations, i.e. More...
 
ChVector< Real > operator* (const ChVector< Real > &V) const
 The '*' operator transforms a vector, so transformations can be represented with this syntax: new_v = tr_frame * old_v; For a sequence of transformations, i.e. More...
 
ChVector< Real > operator/ (const ChVector< Real > &V) const
 The '/' is like the '*' operator (see), but uses the inverse transformation for A, in A/b. More...
 
ChFrame< Real > & operator>>= (const ChFrame< Real > &T)
 Performs pre-multiplication of this frame by another frame, for example: A>>=T means A'=T*A ; or A'=A >> T.
 
ChFrame< Real > & operator%= (const ChFrame< Real > &T)
 Performs pre-multiplication of this frame by another frame, for example: A%=T means A'=T*A ; or A'=A >> T Note: DEPRECATED, use >>= instead.
 
ChFrame< Real > & operator*= (const ChFrame< Real > &T)
 Performs post-multiplication of this frame by another frame, for example: A*=T means A'=A*T ; or A'=T >> A.
 
ChFrame< Real > & operator>>= (const ChVector< Real > &D)
 Performs pre-multiplication of this frame by a vector D, to 'move' by a displacement D:
 
ChFrame< Real > & operator>>= (const ChQuaternion< Real > &R)
 Performs pre-multiplication of this frame by a quaternion R, to 'rotate' it by R:
 
ChFrame< Real > & operator>>= (const ChCoordsys< Real > &F)
 Performs pre-multiplication of this frame by a ChCoordsys F, to transform it:
 
ChCoordsys< Real > & GetCoord ()
 Return both current rotation and translation as a coordsystem object, with vector and quaternion.
 
const ChCoordsys< Real > & GetCoord () const
 
ChVector< Real > & GetPos ()
 Return the current translation as a 3d vector.
 
const ChVector< Real > & GetPos () const
 
ChQuaternion< Real > & GetRot ()
 Return the current rotation as a quaternion.
 
const ChQuaternion< Real > & GetRot () const
 
ChMatrix33< Real > & GetA ()
 Return the current rotation as a 3x3 matrix.
 
const ChMatrix33< Real > & GetA () const
 
ChVector< Real > GetRotAxis ()
 Get axis of finite rotation, in parent space.
 
Real GetRotAngle ()
 Get angle of rotation about axis of finite rotation.
 
virtual void SetCoord (const ChCoordsys< Real > &mcoord)
 Impose both translation and rotation as a single ChCoordsys. More...
 
virtual void SetCoord (const ChVector< Real > &mv, const ChQuaternion< Real > &mq)
 Impose both translation and rotation. More...
 
virtual void SetRot (const ChQuaternion< Real > &mrot)
 Impose the rotation as a quaternion. More...
 
virtual void SetRot (const ChMatrix33< Real > &mA)
 Impose the rotation as a 3x3 matrix. More...
 
virtual void SetPos (const ChVector< Real > &mpos)
 Impose the translation.
 
void ConcatenatePreTransformation (const ChFrame< Real > &T)
 Apply a transformation (rotation and translation) represented by another ChFrame T. More...
 
void ConcatenatePostTransformation (const ChFrame< Real > &T)
 Apply a transformation (rotation and translation) represented by another ChFrame T in local coordinate. More...
 
void Move (const ChVector< Real > &V)
 An easy way to move the frame by the amount specified by vector V, (assuming V expressed in parent coordinates)
 
void Move (const ChCoordsys< Real > &VR)
 Apply both translation and rotation, assuming both expressed in parent coordinates, as a vector for translation and quaternion for rotation,.
 
virtual ChVector< Real > TransformLocalToParent (const ChVector< Real > &local) const
 This function transforms a point from the local frame coordinate system to the parent coordinate system. More...
 
virtual ChVector< Real > TransformPointLocalToParent (const ChVector< Real > &local) const
 
virtual ChVector< Real > TransformParentToLocal (const ChVector< Real > &parent) const
 This function transforms a point from the parent coordinate system to local frame coordinate system. More...
 
virtual ChVector< Real > TransformPointParentToLocal (const ChVector< Real > &parent) const
 
virtual void TransformLocalToParent (const ChFrame< Real > &local, ChFrame< Real > &parent) const
 This function transforms a frame from 'this' local coordinate system to parent frame coordinate system. More...
 
virtual void TransformParentToLocal (const ChFrame< Real > &parent, ChFrame< Real > &local) const
 This function transforms a frame from the parent coordinate system to 'this' local frame coordinate system. More...
 
virtual ChVector< Real > TransformDirectionParentToLocal (const ChVector< Real > &mdirection) const
 This function transforms a direction from 'this' local coordinate system to parent frame coordinate system. More...
 
virtual ChVector< Real > TransformDirectionLocalToParent (const ChVector< Real > &mdirection) const
 This function transforms a direction from the parent frame coordinate system to 'this' local coordinate system. More...
 
bool Equals (const ChFrame< Real > &other) const
 Returns true if coordsys is identical to other coordsys.
 
bool Equals (const ChFrame< Real > &other, Real tol) const
 Returns true if coordsys is equal to other coordsys, within a tolerance 'tol'.
 
void Normalize ()
 Normalize the rotation, so that quaternion has unit length.
 
virtual void SetIdentity ()
 Sets to no translation and no rotation.
 
virtual void Invert ()
 The transformation is inverted in place. More...
 
ChFrame< Real > GetInverse () const
 
virtual void ArchiveOUT (ChArchiveOut &marchive)
 Method to allow serialization of transient data to archives.
 
virtual void ArchiveIN (ChArchiveIn &marchive)
 Method to allow de-serialization of transient data from archives.
 

Public Attributes

ChCoordsys< Real > coord
 Rotation and position, as vector+quaternion.
 
ChMatrix33< Real > Amatrix
 3x3 orthogonal rotation matrix
 

Member Function Documentation

◆ ConcatenatePostTransformation()

template<class Real = double>
void chrono::ChFrame< Real >::ConcatenatePostTransformation ( const ChFrame< Real > &  T)
inline

Apply a transformation (rotation and translation) represented by another ChFrame T in local coordinate.

This is equivalent to post-multiply this frame by the other frame T: this'= this * T; or this'= T >> this

◆ ConcatenatePreTransformation()

template<class Real = double>
void chrono::ChFrame< Real >::ConcatenatePreTransformation ( const ChFrame< Real > &  T)
inline

Apply a transformation (rotation and translation) represented by another ChFrame T.

This is equivalent to pre-multiply this frame by the other frame T: this'= T * this; or this' = this >> T

◆ Invert()

template<class Real = double>
virtual void chrono::ChFrame< Real >::Invert ( )
inlinevirtual

The transformation is inverted in place.

That is if w=A*v, then A.Invert();v=A*w;

Reimplemented in chrono::ChFrameMoving< Real >, and chrono::ChFrameMoving< double >.

◆ operator*() [1/2]

template<class Real = double>
ChFrame<Real> chrono::ChFrame< Real >::operator* ( const ChFrame< Real > &  Fb) const
inline

The '>>' operator transforms a vector, so transformations can be represented with this syntax: new_v = old_v >> tr_frame; For a sequence of transformations, i.e.

a chain of coordinate systems, you can also write this (like you would do with a sequence of Denavitt-Hartemberg matrix multiplications, but in the opposite order...) new_v = old_v >> frame3to2 >> frame2to1 >> frame1to0; This operation is not commutative. The '*' operator transforms a coordinate system, so transformations can be represented with this syntax: new_frame = tr_frame * old_frame; For a sequence of transformations, i.e. a chain of coordinate systems, you can also write this (just like you would do with a sequence of Denavitt-Hartemberg matrix multiplications!) new_frame = frame1to0 * frame2to1 * frame3to2 * old_frame; This operation is not commutative. NOTE: since c++ operator execution is from left to right, in case of multiple transformations like w=A*B*C*v, the >> operator performs faster, like w=v>>C>>B>>A;

◆ operator*() [2/2]

template<class Real = double>
ChVector<Real> chrono::ChFrame< Real >::operator* ( const ChVector< Real > &  V) const
inline

The '*' operator transforms a vector, so transformations can be represented with this syntax: new_v = tr_frame * old_v; For a sequence of transformations, i.e.

a chain of coordinate systems, you can also write this (just like you would do with a sequence of Denavitt-Hartemberg matrix multiplications!) new_v = frame1to0 * frame2to1 * frame3to2 * old_v; This operation is not commutative. NOTE: since c++ operator execution is from left to right, in case of multiple transformations like w=A*B*C*v, the >> operator performs faster, like w=v>>C>>B>>A;

◆ operator/()

template<class Real = double>
ChVector<Real> chrono::ChFrame< Real >::operator/ ( const ChVector< Real > &  V) const
inline

The '/' is like the '*' operator (see), but uses the inverse transformation for A, in A/b.

(with A ChFrame, b ChVector) That is: c=A*b ; b=A/c;

◆ operator>>()

template<class Real = double>
ChFrame<Real> chrono::ChFrame< Real >::operator>> ( const ChFrame< Real > &  Fb) const
inline

The '>>' operator transforms a coordinate system, so transformations can be represented with this syntax: new_frame = old_frame >> tr_frame; For a sequence of transformations, i.e.

a chain of coordinate systems, you can also write this (like you would do with a sequence of Denavitt-Hartemberg matrix multiplications, but in the opposite order...) new_frame = old_frame >> frame3to2 >> frame2to1 >> frame1to0; This operation is not commutative.

◆ SetCoord() [1/2]

template<class Real = double>
virtual void chrono::ChFrame< Real >::SetCoord ( const ChCoordsys< Real > &  mcoord)
inlinevirtual

Impose both translation and rotation as a single ChCoordsys.

Note: the quaternion part must be already normalized!

◆ SetCoord() [2/2]

template<class Real = double>
virtual void chrono::ChFrame< Real >::SetCoord ( const ChVector< Real > &  mv,
const ChQuaternion< Real > &  mq 
)
inlinevirtual

Impose both translation and rotation.

Note: the quaternion part must be already normalized!

◆ SetRot() [1/2]

template<class Real = double>
virtual void chrono::ChFrame< Real >::SetRot ( const ChMatrix33< Real > &  mA)
inlinevirtual

Impose the rotation as a 3x3 matrix.

Note: the rotation matrix must be already orthogonal!

◆ SetRot() [2/2]

template<class Real = double>
virtual void chrono::ChFrame< Real >::SetRot ( const ChQuaternion< Real > &  mrot)
inlinevirtual

Impose the rotation as a quaternion.

Note: the quaternion must be already normalized!

◆ TransformDirectionLocalToParent()

template<class Real = double>
virtual ChVector<Real> chrono::ChFrame< Real >::TransformDirectionLocalToParent ( const ChVector< Real > &  mdirection) const
inlinevirtual

This function transforms a direction from the parent frame coordinate system to 'this' local coordinate system.

Returns
The direction in parent frame coordinate

◆ TransformDirectionParentToLocal()

template<class Real = double>
virtual ChVector<Real> chrono::ChFrame< Real >::TransformDirectionParentToLocal ( const ChVector< Real > &  mdirection) const
inlinevirtual

This function transforms a direction from 'this' local coordinate system to parent frame coordinate system.

Returns
The direction in local frame coordinate

◆ TransformLocalToParent() [1/2]

template<class Real = double>
virtual void chrono::ChFrame< Real >::TransformLocalToParent ( const ChFrame< Real > &  local,
ChFrame< Real > &  parent 
) const
inlinevirtual

This function transforms a frame from 'this' local coordinate system to parent frame coordinate system.

Returns
The frame in parent frame coordinate
Parameters
localframe to transform, given in local frame coordinates
parenttransformed frame, in parent coordinates, will be stored here

◆ TransformLocalToParent() [2/2]

template<class Real = double>
virtual ChVector<Real> chrono::ChFrame< Real >::TransformLocalToParent ( const ChVector< Real > &  local) const
inlinevirtual

This function transforms a point from the local frame coordinate system to the parent coordinate system.

OPTIMIZED FOR SPEED. Since it will use the auxiliary rotation matrix of the ChFrame object, this function is about 50% faster than TransformParentToLocal of a ChCoordsys.

Returns
The point in parent coordinate

◆ TransformParentToLocal() [1/2]

template<class Real = double>
virtual void chrono::ChFrame< Real >::TransformParentToLocal ( const ChFrame< Real > &  parent,
ChFrame< Real > &  local 
) const
inlinevirtual

This function transforms a frame from the parent coordinate system to 'this' local frame coordinate system.

Returns
The frame in local frame coordinate
Parameters
parentframe to transform, given in parent coordinates
localtransformed frame, in local coordinates, will be stored here

◆ TransformParentToLocal() [2/2]

template<class Real = double>
virtual ChVector<Real> chrono::ChFrame< Real >::TransformParentToLocal ( const ChVector< Real > &  parent) const
inlinevirtual

This function transforms a point from the parent coordinate system to local frame coordinate system.

OPTIMIZED FOR SPEED. Since it will use the auxiliary rotation matrix of the ChFrame object, this function is about 50% faster than TransformParentToLocal method of a ChCoordsys.

Returns
The point in local frame coordinate

The documentation for this class was generated from the following file:
  • /builds/uwsbel/chrono/src/chrono/core/ChFrame.h