Loading...
Searching...
No Matches
SBDTypeSpatialTransform Class Reference

This class describes spatial transforms. More...

Accessors

SBMatrix33orientation
 The pointer to the orientation of the spatial transform.
 
SBPosition3position
 The pointer to the position of the spatial transform.
 
SBVector3scale
 The pointer to the scale of the spatial transform.
 
static const SBDTypeSpatialTransform zero
 The zero spatial transform.
 
static const SBDTypeSpatialTransform identity
 The identity spatial transform.
 
SBVector3 getE1 () const
 Returns the first column of the orientation matrix.
 
SBVector3 getE2 () const
 Returns the second column of the orientation matrix.
 
SBVector3 getE3 () const
 Returns the third column of the orientation matrix.
 
SBPosition3 getE4 () const
 Returns the position vector.
 
SBVector3 getE5 () const
 Returns the scale vector.
 
void setE1 (const SBVector3 &v)
 Sets the first column of the orientation matrix to v.
 
void setE2 (const SBVector3 &v)
 Sets the second column of the orientation matrix to v.
 
void setE3 (const SBVector3 &v)
 Sets the third column of the orientation matrix to v.
 
void setE4 (const SBPosition3 &p)
 Sets the position vector to p.
 
void setE5 (const SBVector3 &p)
 Sets the scale vector to p.
 

Constructors and destructor

 SBDTypeSpatialTransform ()
 Constructs an identity transform.
 
 SBDTypeSpatialTransform (const SBDTypeSpatialTransform &transform)
 Copy constructor.
 
 SBDTypeSpatialTransform (SBDTypeSpatialTransform &&transform)
 Move constructor.
 
 SBDTypeSpatialTransform (const SBPosition3 &position)
 Constructs a transform from a position vector, the orientation matrix is set to identity.
 
 SBDTypeSpatialTransform (const SBMatrix33 &orientation)
 Constructs a transform from an orientation matrix, the position vector is set to zero.
 
 SBDTypeSpatialTransform (const SBMatrix33 &orientation, const SBPosition3 &position)
 Constructs a transform from an orientation matrix and a position vector.
 
 SBDTypeSpatialTransform (const SBMatrix33 &orientation, const SBPosition3 &position, const SBVector3 &scale)
 Constructs a transform from an orientation matrix, a position vector and a scale.
 
 ~SBDTypeSpatialTransform ()
 Destroys the spatial transform.
 

Serialization

virtual bool isSerializable () const
 Returns true.
 
virtual void serialize (SBCSerializer *serializer, const SBVersionNumber &sdkVersionNumber=SB_SDK_VERSION_NUMBER) const
 Serializes the spatial transform.
 
virtual void unserialize (SBCSerializer *serializer, const SBVersionNumber &sdkVersionNumber=SB_SDK_VERSION_NUMBER)
 Unserializes the spatial transform.
 

Operators

SBPosition3 operator* (const SBPosition3 &position) const
 Returns the result of the transformation of position position by this transform.
 
SBVelocity6 operator* (const SBVelocity6 &velocity) const
 Returns the result of the transformation of spatial velocity velocity by this transform.
 
SBAcceleration6 operator* (const SBAcceleration6 &acceleration) const
 Returns the result of the transformation of spatial acceleration acceleration by this transform.
 
SBForce6 operator* (const SBForce6 &force) const
 Returns the result of the transformation of spatial force force by this transform.
 
SBDTypeSpatialTransform operator* (const SBDTypeSpatialTransform &transform) const
 Returns the product of this transform with the transform transform.
 
SBDTypeSpatialTransformoperator= (const SBDTypeSpatialTransform &transform)
 Copy assignment.
 
SBDTypeSpatialTransformoperator= (SBDTypeSpatialTransform &&transform)
 Move assignment.
 
bool operator== (const SBDTypeSpatialTransform &transform) const
 Returns true if and only if this transform is equal to transform.
 
bool operator!= (const SBDTypeSpatialTransform &transform) const
 Returns true if and only if this transform is not equal to transform.
 

Useful functions

void setIdentity ()
 Sets this transform to identity.
 
void computeOpenGLMatrix (float mat[16]) const
 Stores the OpenGL matrix corresponding to this transform in mat.
 
void computeOpenGLMatrix (double mat[16]) const
 Stores the OpenGL matrix corresponding to this transform in mat.
 
void inverse (SBDTypeSpatialTransform &inverse) const
 Stores the inverse of this transform in inverse.
 
SBDTypeSpatialTransform inverse () const
 Returns the inverse of this transform.
 
void rightMultiply3D (const SBDTypeSpatialTransform &leftMember, SBDTypeSpatialTransform &result) const
 Stores in result the product of leftMember and this transform.
 
void rightMultiplyInverse3D (const SBDTypeSpatialTransform &leftMember, SBDTypeSpatialTransform &result) const
 Stores in result the product of leftMember and the inverse of this transform.
 
void print () const
 Prints the spatial transform.
 
static SBDTypeSpatialTransform fromAlignment (const SBVector< SBPosition3 > &fromPositionVector, const SBVector< SBPosition3 > &toPositionVector, SBQuantity::length &preRMSD, SBQuantity::length &postRMSD)
 Returns the transform that transforms the positions in fromPositionVector into the positions in toPositionVector as best as possible.
 

Transformations

void transformPoint (const SBPosition3 &p, SBPosition3 &result) const
 Transforms the point p into the point result.
 
void transformVelocity (const SBVelocity6 &velocityA, SBVelocity6 &velocityB) const
 Transforms the spatial velocity velocityA into the spatial velocity velocityB.
 
void transformAcceleration (const SBAcceleration6 &accelerationA, SBAcceleration6 &accelerationB) const
 Transforms the spatial acceleration accelerationA into the spatial acceleration accelerationB.
 
void inverseTransformVelocity (const SBVelocity6 &motionA, SBVelocity6 &motionB) const
 Transforms the spatial velocity velocityA into the spatial velocity velocityB by applying the inverse of this transform.
 
void inverseTransformAcceleration (const SBAcceleration6 &motionA, SBAcceleration6 &motionB) const
 Transforms the spatial acceleration accelerationA into the spatial acceleration accelerationB by applying the inverse of this transform.
 
void transformForce (const SBForce6 &forceA, SBForce6 &forceB) const
 Transforms the spatial force forceA into the spatial force forceB.
 
void transformInverseInertia (const SBInverseInertia66 &phiA, SBInverseInertia66 &phiB) const
 Transforms the inverse inertia phiA into the inverse inertia phiB.
 
void transformInverseInertiaLeft (const SBInverseInertia66 &phi, SBInverseInertia66 &result) const
 Left-multiplies the inverse inertia phi by this spatial transform and stores the result in result.
 
void transformInverseInertiaRight (const SBInverseInertia66 &phi, SBInverseInertia66 &result) const
 Right-multiplies the inverse inertia phi by this spatial transform and stores the result in result.
 
void transformInverseInertiaTransposeRight (const SBInverseInertia66 &phi, SBInverseInertia66 &result) const
 Right-multiplies the transpose of the inverse inertia phi by this spatial transform and stores the result in result.
 
void transformInertia (const SBInertia66 &IA, SBInertia66 &IB) const
 Transforms the inertia IA by this spatial transform and stores the result in IB.
 
void transformInertiaLeft (const SBInertia66 &I, SBInertia66 &result) const
 Left-multiplies the inertia I by this spatial transform and stores the result in result.
 
void transformInertiaRight (const SBInertia66 &I, SBInertia66 &result) const
 Right-multiplies the inertia I by this spatial transform and stores the result in result.
 

Detailed Description

This class handles rigid body transforms, and includes some useful functions to treat the transform either as a regular 3D transform (e.g. to transform points) or as a spatial transform (e.g. to transform spatial velocities, spatial accelerations, spatial inertias, etc.). A spatial transform is composed of an orientation part (SBMatrix33) and a position part (SBPosition3).

Short name: SBSpatialTransform

See also
The SBDType library
SBDTypePhysicalVector3
SBDTypeMatrix33

Member Function Documentation

◆ computeOpenGLMatrix() [1/2]

void SBDTypeSpatialTransform::computeOpenGLMatrix ( double  mat[16]) const

Stores the OpenGL matrix corresponding to this transform in mat:

mat[0] = scale->v[0].getValue() * orientation->m[0][0].getValue();
mat[1] = scale->v[0].getValue() * orientation->m[1][0].getValue();
mat[2] = scale->v[0].getValue() * orientation->m[2][0].getValue();
mat[3] = 0.0f;
mat[4] = scale->v[1].getValue() * orientation->m[0][1].getValue();
mat[5] = scale->v[1].getValue() * orientation->m[1][1].getValue();
mat[6] = scale->v[1].getValue() * orientation->m[2][1].getValue();
mat[7] = 0.0f;
mat[8] = scale->v[2].getValue() * orientation->m[0][2].getValue();
mat[9] = scale->v[2].getValue() * orientation->m[1][2].getValue();
mat[10] = scale->v[2].getValue() * orientation->m[2][2].getValue();
mat[11] = 0.0f;
mat[12] = position->v[0].getValue();
mat[13] = position->v[1].getValue();
mat[14] = position->v[2].getValue();
mat[15] = 1.0f;
constexpr Value const & getValue() const noexcept
Returns the value.
Definition: SBDQuantityType.hpp:94
Quantity m[3][3]
The components of the physical matrix.
Definition: SBDTypePhysicalMatrix33.hpp:1302
Quantity v[3]
The components of the physical vector.
Definition: SBDTypePhysicalVector3.hpp:768
SBMatrix33 * orientation
The pointer to the orientation of the spatial transform.
Definition: SBDTypeSpatialTransform.hpp:124
SBPosition3 * position
The pointer to the position of the spatial transform.
Definition: SBDTypeSpatialTransform.hpp:125
SBVector3 * scale
The pointer to the scale of the spatial transform.
Definition: SBDTypeSpatialTransform.hpp:126

◆ computeOpenGLMatrix() [2/2]

void SBDTypeSpatialTransform::computeOpenGLMatrix ( float  mat[16]) const

Stores the OpenGL matrix corresponding to this transform in mat:

mat[0] = (float)scale->v[0].getValue() * (float)orientation->m[0][0].getValue();
mat[1] = (float)scale->v[0].getValue() * (float)orientation->m[1][0].getValue();
mat[2] = (float)scale->v[0].getValue() * (float)orientation->m[2][0].getValue();
mat[3] = 0.0f;
mat[4] = (float)scale->v[1].getValue() * (float)orientation->m[0][1].getValue();
mat[5] = (float)scale->v[1].getValue() * (float)orientation->m[1][1].getValue();
mat[6] = (float)scale->v[1].getValue() * (float)orientation->m[2][1].getValue();
mat[7] = 0.0f;
mat[8] = (float)scale->v[2].getValue() * (float)orientation->m[0][2].getValue();
mat[9] = (float)scale->v[2].getValue() * (float)orientation->m[1][2].getValue();
mat[10] = (float)scale->v[2].getValue() * (float)orientation->m[2][2].getValue();
mat[11] = 0.0f;
mat[12] = (float)position->v[0].getValue();
mat[13] = (float)position->v[1].getValue();
mat[14] = (float)position->v[2].getValue();
mat[15] = 1.0f;

◆ inverse()

void SBDTypeSpatialTransform::inverse ( SBDTypeSpatialTransform inverse) const

Note that this function only provides correct results when the scale is uniform.

◆ operator*()

SBDTypeSpatialTransform SBDTypeSpatialTransform::operator* ( const SBDTypeSpatialTransform transform) const

Note that this function only provides correct results when the scales are uniform.