Simbody  3.7
SimTK::SpatialInertia_< P > Class Template Reference

A spatial inertia contains the mass, center of mass point, and inertia matrix for a rigid body. More...

## Public Member Functions

SpatialInertia_ ()
The default constructor fills everything with NaN, even in Release mode. More...

SpatialInertia_ (RealP mass, const Vec3P &com, const UnitInertiaP &gyration)

SpatialInertia_setMass (RealP mass)

SpatialInertia_setMassCenter (const Vec3P &com)

SpatialInertia_setUnitInertia (const UnitInertiaP &gyration)

RealP getMass () const

const Vec3PgetMassCenter () const

const UnitInertiaPgetUnitInertia () const

Vec3P calcMassMoment () const
Calculate the first mass moment (mass-weighted COM location) from the mass and COM vector. More...

InertiaP calcInertia () const
Calculate the inertia matrix (second mass moment, mass-weighted gyration matrix) from the mass and unit inertia matrix. More...

SpatialInertia_operator+= (const SpatialInertia_ &src)
Add in a compatible SpatialInertia. More...

SpatialInertia_operator-= (const SpatialInertia_ &src)
Subtract off a compatible SpatialInertia. More...

SpatialInertia_operator*= (const RealP &s)
Multiply a SpatialInertia by a scalar. More...

SpatialInertia_operator/= (const RealP &s)
Divide a SpatialInertia by a scalar. More...

SpatialVecP operator* (const SpatialVecP &v) const
Multiply a SpatialInertia by a SpatialVec to produce a SpatialVec result; 45 flops. More...

SpatialInertia_ reexpress (const Rotation_< P > &R_FB) const
Return a new SpatialInertia object which is the same as this one except re-expressed in another coordinate frame. More...

SpatialInertia_ reexpress (const InverseRotation_< P > &R_FB) const
Rexpress using an inverse rotation to avoid having to convert it. More...

SpatialInertia_reexpressInPlace (const Rotation_< P > &R_FB)
Re-express this SpatialInertia in another frame, modifying the original object. More...

SpatialInertia_reexpressInPlace (const InverseRotation_< P > &R_FB)
Rexpress using an inverse rotation to avoid having to convert it. More...

SpatialInertia_ shift (const Vec3P &S) const
Return a new SpatialInertia object which is the same as this one except the origin ("taken about" point) has changed from OF to OF+S. More...

SpatialInertia_shiftInPlace (const Vec3P &S)
Change origin from OF to OF+S, modifying the original object in place. More...

SpatialInertia_ transform (const Transform_< P > &X_FB) const
Return a new SpatialInertia object which is the same as this one but measured about and expressed in a new frame. More...

SpatialInertia_ transform (const InverseTransform_< P > &X_FB) const
Transform using an inverse transform to avoid having to convert it. More...

SpatialInertia_transformInPlace (const Transform_< P > &X_FB)
Transform this SpatialInertia object so that it is measured about and expressed in a new frame, modifying the object in place. More...

SpatialInertia_transformInPlace (const InverseTransform_< P > &X_FB)
Transform using an inverse transform to avoid having to convert it. More...

const SpatialMatP toSpatialMat () const

## Related Functions

(Note that these are not member functions.)

template<class P >
SpatialInertia_< P > operator+ (const SpatialInertia_< P > &l, const SpatialInertia_< P > &r)
Add two compatible spatial inertias. More...

template<class P >
SpatialInertia_< P > operator- (const SpatialInertia_< P > &l, const SpatialInertia_< P > &r)
Subtract one compatible spatial inertia from another. More...

## Detailed Description

### template<class P> class SimTK::SpatialInertia_< P >

A spatial inertia contains the mass, center of mass point, and inertia matrix for a rigid body.

This is 10 independent quantities altogether; however, inertia is mass-scaled making it linearly dependent on the mass. Here instead we represent inertia using a unit inertia matrix, which is equivalent to the inertia this body would have if it had unit mass. Then the actual inertia is given by mass*unitInertia. In this manner the mass, center of mass location, and inertia are completely independent so can be changed separately. That means if you double the mass, you'll also double the inertia as you would expect.

Spatial inertia may be usefully viewed as a symmetric spatial matrix, that is, a 6x6 symmetric matrix arranged as 2x2 blocks of 3x3 matrices. Although this class represents the spatial inertia in compact form, it supports methods and operators that allow it to behave as though it were a spatial matrix (except much faster to work with). In spatial matrix form, the matrix has the following interpretation:

```              [  m*G   m*px ]
M = [             ]
[ -m*px  m*I  ]
```

Here m is mass, p is the vector from the body origin to the center of mass, G is the 3x3 symmetric unit inertia (gyration) matrix, and I is a 3x3 identity matrix. "px" indicates the skew symmetric cross product matrix formed from the vector p, so -px=~px.

### Abbreviations

Typedefs exist for the most common invocations of SpatialInertia_<P>:

## ◆ SpatialInertia_() [1/2]

template<class P>
 SimTK::SpatialInertia_< P >::SpatialInertia_ ( )
inline

The default constructor fills everything with NaN, even in Release mode.

## ◆ SpatialInertia_() [2/2]

template<class P>
 SimTK::SpatialInertia_< P >::SpatialInertia_ ( RealP mass, const Vec3P & com, const UnitInertiaP & gyration )
inline

## ◆ setMass()

template<class P>
 SpatialInertia_& SimTK::SpatialInertia_< P >::setMass ( RealP mass )
inline

## ◆ setMassCenter()

template<class P>
 SpatialInertia_& SimTK::SpatialInertia_< P >::setMassCenter ( const Vec3P & com )
inline

## ◆ setUnitInertia()

template<class P>
 SpatialInertia_& SimTK::SpatialInertia_< P >::setUnitInertia ( const UnitInertiaP & gyration )
inline

## ◆ getMass()

template<class P>
 RealP SimTK::SpatialInertia_< P >::getMass ( ) const
inline

## ◆ getMassCenter()

template<class P>
 const Vec3P& SimTK::SpatialInertia_< P >::getMassCenter ( ) const
inline

## ◆ getUnitInertia()

template<class P>
 const UnitInertiaP& SimTK::SpatialInertia_< P >::getUnitInertia ( ) const
inline

## ◆ calcMassMoment()

template<class P>
 Vec3P SimTK::SpatialInertia_< P >::calcMassMoment ( ) const
inline

Calculate the first mass moment (mass-weighted COM location) from the mass and COM vector.

Cost is 3 inline flops.

## ◆ calcInertia()

template<class P>
 InertiaP SimTK::SpatialInertia_< P >::calcInertia ( ) const
inline

Calculate the inertia matrix (second mass moment, mass-weighted gyration matrix) from the mass and unit inertia matrix.

Cost is 6 inline flops.

## ◆ operator+=()

template<class P>
 SpatialInertia_& SimTK::SpatialInertia_< P >::operator+= ( const SpatialInertia_< P > & src )
inline

Add in a compatible SpatialInertia.

This is only valid if both SpatialInertias are expressed in the same frame and measured about the same point but there is no way for this method to check. Cost is about 40 flops.

## ◆ operator-=()

template<class P>
 SpatialInertia_& SimTK::SpatialInertia_< P >::operator-= ( const SpatialInertia_< P > & src )
inline

Subtract off a compatible SpatialInertia.

This is only valid if both SpatialInertias are expressed in the same frame and measured about the same point but there is no way for this method to check. Cost is about 40 flops.

## ◆ operator*=()

template<class P>
 SpatialInertia_& SimTK::SpatialInertia_< P >::operator*= ( const RealP & s )
inline

Multiply a SpatialInertia by a scalar.

Because we keep the mass factored out, this requires only a single multiply.

## ◆ operator/=()

template<class P>
 SpatialInertia_& SimTK::SpatialInertia_< P >::operator/= ( const RealP & s )
inline

Divide a SpatialInertia by a scalar.

Because we keep the mass factored out, this requires only a single divide.

## ◆ operator*()

template<class P>
 SpatialVecP SimTK::SpatialInertia_< P >::operator* ( const SpatialVecP & v ) const
inline

Multiply a SpatialInertia by a SpatialVec to produce a SpatialVec result; 45 flops.

## ◆ reexpress() [1/2]

template<class P>
 SpatialInertia_ SimTK::SpatialInertia_< P >::reexpress ( const Rotation_< P > & R_FB ) const
inline

Return a new SpatialInertia object which is the same as this one except re-expressed in another coordinate frame.

We consider this object to be expressed in some frame F and we're given a rotation matrix R_FB we can use to re-express in a new frame B. Cost is 72 flops.

reexpressInPlace()

## ◆ reexpress() [2/2]

template<class P>
 SpatialInertia_ SimTK::SpatialInertia_< P >::reexpress ( const InverseRotation_< P > & R_FB ) const
inline

Rexpress using an inverse rotation to avoid having to convert it.

rexpress(Rotation) for information

## ◆ reexpressInPlace() [1/2]

template<class P>
 SpatialInertia_& SimTK::SpatialInertia_< P >::reexpressInPlace ( const Rotation_< P > & R_FB )
inline

Re-express this SpatialInertia in another frame, modifying the original object.

We return a reference to the object so that you can chain this operation in the manner of assignment operators. Cost is 72 flops.

reexpress() if you want to leave this object unmolested.

## ◆ reexpressInPlace() [2/2]

template<class P>
 SpatialInertia_& SimTK::SpatialInertia_< P >::reexpressInPlace ( const InverseRotation_< P > & R_FB )
inline

Rexpress using an inverse rotation to avoid having to convert it.

rexpressInPlace(Rotation) for information

## ◆ shift()

template<class P>
 SpatialInertia_ SimTK::SpatialInertia_< P >::shift ( const Vec3P & S ) const
inline

Return a new SpatialInertia object which is the same as this one except the origin ("taken about" point) has changed from OF to OF+S.

Cost is 37 flops.

shiftInPlace()

## ◆ shiftInPlace()

template<class P>
 SpatialInertia_& SimTK::SpatialInertia_< P >::shiftInPlace ( const Vec3P & S )
inline

Change origin from OF to OF+S, modifying the original object in place.

Returns a reference to the modified object so that you can chain this operation in the manner of assignment operators. Cost is 37 flops.

shift() if you want to leave this object unmolested.

## ◆ transform() [1/2]

template<class P>
 SpatialInertia_ SimTK::SpatialInertia_< P >::transform ( const Transform_< P > & X_FB ) const
inline

Return a new SpatialInertia object which is the same as this one but measured about and expressed in a new frame.

We consider the current spatial inertia M to be measured (implicitly) in some frame F, that is, we have M=M_OF_F. We want M_OB_B for some new frame B, given the transform X_FB giving the location and orientation of B in F. This combines the reexpress() and shift() operations available separately. Cost is 109 flops.

transformInPlace()

## ◆ transform() [2/2]

template<class P>
 SpatialInertia_ SimTK::SpatialInertia_< P >::transform ( const InverseTransform_< P > & X_FB ) const
inline

Transform using an inverse transform to avoid having to convert it.

transform(Transform) for information

## ◆ transformInPlace() [1/2]

template<class P>
 SpatialInertia_& SimTK::SpatialInertia_< P >::transformInPlace ( const Transform_< P > & X_FB )
inline

Transform this SpatialInertia object so that it is measured about and expressed in a new frame, modifying the object in place.

We consider the current spatial inertia M to be measured (implicitly) in some frame F, that is, we have M=M_OF_F. We want to change it to M_OB_B for some new frame B, given the transform X_FB giving the location and orientation of B in F. This combines the reexpressInPlace() and shiftInPlace() operations available separately. Returns a reference to the modified object so that you can chain this operation in the manner of assignment operators. Cost is 109 flops.

transform() if you want to leave this object unmolested.

## ◆ transformInPlace() [2/2]

template<class P>
 SpatialInertia_& SimTK::SpatialInertia_< P >::transformInPlace ( const InverseTransform_< P > & X_FB )
inline

Transform using an inverse transform to avoid having to convert it.

transformInPlace(Transform) for information

## ◆ toSpatialMat()

template<class P>
 const SpatialMatP SimTK::SpatialInertia_< P >::toSpatialMat ( ) const
inline

## ◆ operator+()

template<class P >
 SpatialInertia_< P > operator+ ( const SpatialInertia_< P > & l, const SpatialInertia_< P > & r )
related

Add two compatible spatial inertias.

Cost is about 40 flops.

## ◆ operator-()

template<class P >
 SpatialInertia_< P > operator- ( const SpatialInertia_< P > & l, const SpatialInertia_< P > & r )
related

Subtract one compatible spatial inertia from another.

Cost is about 40 flops.

The documentation for this class was generated from the following file: