Simbody
3.7

The physical meaning of an inertia is the distribution of a rigid body's mass about a particular point. More...
Public Member Functions  
Inertia_ ()  
Default is a NaNed out mess to avoid accidents, even in Release mode. More...  
Inertia_ (const P &moment)  
Create a principal inertia matrix with identical diagonal elements, like a sphere where moment=2/5 m r^2, or a cube where moment=1/6 m s^2, with m the total mass, r the sphere's radius and s the length of a side of the cube. More...  
Inertia_ (const Vec< 3, P > &p, const P &mass)  
Create an Inertia matrix for a point mass at a given location, measured from the origin OF of the implicit frame F, and expressed in F. More...  
Inertia_ (const Vec< 3, P > &moments, const Vec< 3, P > &products=Vec< 3, P >(0))  
Create an inertia matrix from a vector of the moments of inertia (the inertia matrix diagonal) and optionally a vector of the products of inertia (the offdiagonals). More...  
Inertia_ (const P &xx, const P &yy, const P &zz)  
Create a principal inertia matrix (only nonzero on diagonal). More...  
Inertia_ (const P &xx, const P &yy, const P &zz, const P &xy, const P &xz, const P &yz)  
This is a general inertia matrix. More...  
Inertia_ (const SymMat< 3, P > &inertia)  
Construct an Inertia from a symmetric 3x3 matrix. More...  
Inertia_ (const Mat< 3, 3, P > &m)  
Construct an Inertia matrix from a 3x3 symmetric matrix. More...  
Inertia_ &  setInertia (const P &xx, const P &yy, const P &zz) 
Set an inertia matrix to have only principal moments (that is, it will be diagonal). More...  
Inertia_ &  setInertia (const Vec< 3, P > &moments, const Vec< 3, P > &products=Vec< 3, P >(0)) 
Set principal moments and optionally offdiagonal terms. More...  
Inertia_ &  setInertia (const P &xx, const P &yy, const P &zz, const P &xy, const P &xz, const P &yz) 
Set this Inertia to a general matrix. More...  
Inertia_ &  operator+= (const Inertia_ &inertia) 
Add in another inertia matrix. More...  
Inertia_ &  operator= (const Inertia_ &inertia) 
Subtract off another inertia matrix. More...  
Inertia_ &  operator*= (const P &s) 
Multiply this inertia matrix by a scalar. Cost is 6 flops. More...  
Inertia_ &  operator/= (const P &s) 
Divide this inertia matrix by a scalar. More...  
Inertia_  shiftToMassCenter (const Vec< 3, P > &CF, const P &mass) const 
Assume that the current inertia is about the F frame's origin OF, and expressed in F. More...  
Inertia_ &  shiftToMassCenterInPlace (const Vec< 3, P > &CF, const P &mass) 
Assume that the current inertia is about the F frame's origin OF, and expressed in F. More...  
Inertia_  shiftFromMassCenter (const Vec< 3, P > &p, const P &mass) const 
Assuming that the current inertia I is a central inertia (that is, it is inertia about the body center of mass CF), shift it to some other point p measured from the center of mass. More...  
Inertia_ &  shiftFromMassCenterInPlace (const Vec< 3, P > &p, const P &mass) 
Assuming that the current inertia I is a central inertia (that is, it is inertia about the body center of mass CF), shift it to some other point p measured from the center of mass. More...  
Inertia_  reexpress (const Rotation_< P > &R_FB) const 
Return a new inertia matrix like this one but reexpressed in another frame (leaving the origin point unchanged). More...  
Inertia_  reexpress (const InverseRotation_< P > &R_FB) const 
Rexpress using an inverse rotation to avoid having to convert it. More...  
Inertia_ &  reexpressInPlace (const Rotation_< P > &R_FB) 
Reexpress this inertia matrix in another frame, changing the object in place; see reexpress() if you want to leave this object unmolested and get a new one instead. More...  
Inertia_ &  reexpressInPlace (const InverseRotation_< P > &R_FB) 
Rexpress in place using an inverse rotation to avoid having to convert it. More...  
P  trace () const 
operator const SymMat< 3, P > & () const  
This is an implicit conversion to a const SymMat33. More...  
const SymMat< 3, P > &  asSymMat33 () const 
Obtain a reference to the underlying symmetric matrix type. More...  
Mat< 3, 3, P >  toMat33 () const 
Expand the internal packed representation into a full 3x3 symmetric matrix with all elements set. More...  
const Vec< 3, P > &  getMoments () const 
Obtain the inertia moments (diagonal of the Inertia matrix) as a Vec3 ordered xx, yy, zz. More...  
const Vec< 3, P > &  getProducts () const 
Obtain the inertia products (offdiagonals of the Inertia matrix) as a Vec3 with elements ordered xy, xz, yz. More...  
bool  isNaN () const 
bool  isInf () const 
bool  isFinite () const 
bool  isNumericallyEqual (const Inertia_< P > &other) const 
Compare this inertia matrix with another one and return true if they are close to within a default numerical tolerance. More...  
bool  isNumericallyEqual (const Inertia_< P > &other, double tol) const 
Compare this inertia matrix with another one and return true if they are close to within a specified numerical tolerance. More...  
Static Public Member Functions  
static bool  isValidInertiaMatrix (const SymMat< 3, P > &m) 
Test some conditions that must hold for a valid Inertia matrix. More...  
static Inertia_  pointMassAtOrigin () 
Create an Inertia matrix for a point located at the origin – that is, an allzero matrix. More...  
static Inertia_  pointMassAt (const Vec< 3, P > &p, const P &m) 
Create an Inertia matrix for a point of a given mass, located at a given location measured from the origin of the implicit F frame. More...  
Unit inertia matrix factories  
These return UnitInertia matrices (inertias of unitmass objects) converted to Inertias. Multiply the result by the actual mass to get the Inertia of an actual object of this shape. See the UnitInertia class for more information.  
static Inertia_  sphere (const P &r) 
Create a UnitInertia matrix for a unit mass sphere of radius r centered at the origin. More...  
static Inertia_  cylinderAlongZ (const P &r, const P &hz) 
Unitmass cylinder aligned along z axis; use radius and halflength. More...  
static Inertia_  cylinderAlongY (const P &r, const P &hy) 
Unitmass cylinder aligned along y axis; use radius and halflength. More...  
static Inertia_  cylinderAlongX (const P &r, const P &hx) 
Unitmass cylinder aligned along x axis; use radius and halflength. More...  
static Inertia_  brick (const P &hx, const P &hy, const P &hz) 
Unitmass brick given by halflengths in each direction. More...  
static Inertia_  brick (const Vec< 3, P > &halfLengths) 
Alternate interface to brick() that takes a Vec3 for the half lengths. More...  
static Inertia_  ellipsoid (const P &hx, const P &hy, const P &hz) 
Unitmass ellipsoid given by halflengths in each direction. More...  
static Inertia_  ellipsoid (const Vec< 3, P > &halfLengths) 
Alternate interface to ellipsoid() that takes a Vec3 for the half lengths. More...  
Protected Member Functions  
const UnitInertia_< P > &  getAsUnitInertia () const 
UnitInertia_< P > &  updAsUnitInertia () 
void  errChk (const char *methodName) const 
Protected Attributes  
SymMat< 3, P >  I_OF_F 
Related Functions  
(Note that these are not member functions.)  
template<class P >  
Inertia_< P >  operator+ (const Inertia_< P > &l, const Inertia_< P > &r) 
Add two compatible inertia matrices, meaning they must be taken about the same point and expressed in the same frame. More...  
template<class P >  
Inertia_< P >  operator (const Inertia_< P > &l, const Inertia_< P > &r) 
Subtract from one inertia matrix another one which is compatible, meaning that both must be taken about the same point and expressed in the same frame. More...  
template<class P >  
Inertia_< P >  operator* (const Inertia_< P > &i, const P &r) 
Multiply an inertia matrix by a scalar. More...  
template<class P >  
Inertia_< P >  operator* (const P &r, const Inertia_< P > &i) 
Multiply an inertia matrix by a scalar. More...  
template<class P >  
Inertia_< P >  operator* (const Inertia_< P > &i, int r) 
Multiply an inertia matrix by a scalar given as an int. More...  
template<class P >  
Inertia_< P >  operator* (int r, const Inertia_< P > &i) 
Multiply an inertia matrix by a scalar given as an int. More...  
template<class P >  
Inertia_< P >  operator/ (const Inertia_< P > &i, const P &r) 
Divide an inertia matrix by a scalar. More...  
template<class P >  
Inertia_< P >  operator/ (const Inertia_< P > &i, int r) 
Divide an inertia matrix by a scalar provided as an int. More...  
template<class P >  
Vec< 3, P >  operator* (const Inertia_< P > &I, const Vec< 3, P > &w) 
Multiply an inertia matrix I on the right by a vector w giving the vector result I*w. More...  
template<class P >  
bool  operator== (const Inertia_< P > &i1, const Inertia_< P > &i2) 
Compare two inertia matrices for exact (bitwise) equality. More...  
template<class P >  
std::ostream &  operator<< (std::ostream &o, const Inertia_< P > &inertia) 
Output a humanreadable representation of an inertia matrix to the indicated stream. More...  
The physical meaning of an inertia is the distribution of a rigid body's mass about a particular point.
If that point is the center of mass of the body, then the measured inertia is called the "central inertia" of that body. To write down the inertia, we need to calculate the six scalars of the inertia tensor, which is a symmetric 3x3 matrix. These scalars must be expressed in an arbitrary but specified coordinate system. So an Inertia is meaningful only in conjunction with a particular set of axes, fixed to the body, whose origin is the point about which the inertia is being measured, and in whose coordinate system this measurement is being expressed. Note that changing the reference point results in a new physical quantity, but changing the reference axes only affects the measure numbers of that quantity. For any reference point, there is a unique set of reference axes in which the inertia tensor is diagonal; those are called the "principal axes" of the body at that point, and the resulting diagonal elements are the "principal moments of inertia". When we speak of an inertia being "in" a frame, we mean the physical quantity measured about the frame's origin and then expressed in the frame's axes.
This lowlevel Inertia class does not attempt to keep track of which frame it is in. It provides construction and operations involving inertia that can proceed using only an implicit frame F. Clients of this class are responsible for keeping track of that frame. In particular, in order to shift the inertia's "measuredabout" point one must know whether either the starting or final inertia is central, because we must always shift inertias by passing through the central inertia. So this class provides operations for doing the shifting, but expects to be told by the client where to find the center of mass.
Reexpressing an Inertia in a different coordinate system does not entail a change of physical meaning in the way that shifting it to a different point does. Note that because inertia is a tensor, there is a "left frame" and "right frame". For our purposes, these will always be the same so we'll only indicate the frame once, as in 'I_pt_frame'. This should be understood to mean 'frame_I_pt_frame' and reexpressing an Inertia requires both a left and right multiply by the rotation matrix. So I_OB_B is the inertia about body B's origin point OB, expressed in B, while I_OB_G is the same physical quantity but expressed in Ground (the latter is a component of the Spatial Inertia which we usually want in the Ground frame). Frame conversion is done logically like this:
I_OB_G = R_GB * I_OB_B * R_BG (R_BG=~R_GB)
but we can save computation time by performing this as a single operation.
The central inertia would be I_CB_B for body B.
A Inertia is a symmetric matrix and is positive definite for nonsingular bodies (that is, a body composed of at least three noncollinear point masses).
Some attempt is made to check the validity of an Inertia matrix, at least when running in Debug mode. Some conditions it must satisfy are:
Typedefs exist for the most common invocations of Inertia_<P>:

inline 
Default is a NaNed out mess to avoid accidents, even in Release mode.
Other than this value, an Inertia matrix should always be valid.

inlineexplicit 
Create a principal inertia matrix with identical diagonal elements, like a sphere where moment=2/5 m r^2, or a cube where moment=1/6 m s^2, with m the total mass, r the sphere's radius and s the length of a side of the cube.
Note that many rigid bodies of different shapes and masses can have the same inertia matrix.

inline 
Create an Inertia matrix for a point mass at a given location, measured from the origin OF of the implicit frame F, and expressed in F.
Cost is 14 flops.

inlineexplicit 
Create an inertia matrix from a vector of the moments of inertia (the inertia matrix diagonal) and optionally a vector of the products of inertia (the offdiagonals).
Moments are in the order xx,yy,zz; products are xy,xz,yz.

inline 
Create a principal inertia matrix (only nonzero on diagonal).

inline 
This is a general inertia matrix.
Note the order of these arguments: moments of inertia first, then products of inertia.

inlineexplicit 
Construct an Inertia from a symmetric 3x3 matrix.
The diagonals must be nonnegative and satisfy the triangle inequality.

inlineexplicit 
Construct an Inertia matrix from a 3x3 symmetric matrix.
In Debug mode we'll test that the supplied matrix is numerically close to symmetric, and that it satisfies other requirements of an Inertia matrix.

inline 
Set an inertia matrix to have only principal moments (that is, it will be diagonal).
Returns a reference to "this" like an assignment operator.

inline 
Set principal moments and optionally offdiagonal terms.
Returns a reference to "this" like an assignment operator.

inline 
Set this Inertia to a general matrix.
Note the order of these arguments: moments of inertia first, then products of inertia. Behaves like an assignment statement. Will throw an error message in Debug mode if the supplied elements do not constitute a valid Inertia matrix.

inline 
Add in another inertia matrix.
Frames and reference point must be the same but we can't check. (6 flops)

inline 
Subtract off another inertia matrix.
Frames and reference point must be the same but we can't check. (6 flops)

inline 
Multiply this inertia matrix by a scalar. Cost is 6 flops.

inline 
Divide this inertia matrix by a scalar.
Cost is about 20 flops (a divide and 6 multiplies).

inline 
Assume that the current inertia is about the F frame's origin OF, and expressed in F.
Given the vector from OF to the body center of mass CF, and the mass m of the body, we can shift the inertia to the center of mass. This produces a new Inertia I' whose (implicit) frame F' is aligned with F but has origin CF (an inertia like that is called a "central inertia". I' = I  Icom where Icom is the inertia of a fictitious point mass of mass m (that is, the same as the body mass) located at CF (measured in F) about OF. Cost is 20 flops.

inline 
Assume that the current inertia is about the F frame's origin OF, and expressed in F.
Given the vector from OF to the body center of mass CF, and the mass m of the body, we can shift the inertia to the center of mass. This produces a new Inertia I' whose (implicit) frame F' is aligned with F but has origin CF (an inertia like that is called a "central inertia". I' = I  Icom where Icom is the inertia of a fictitious point mass of mass m (that is, the same as the body mass) located at CF (measured in F) about OF. Cost is 20 flops.

inline 
Assuming that the current inertia I is a central inertia (that is, it is inertia about the body center of mass CF), shift it to some other point p measured from the center of mass.
This produces a new inertia I' about the point p given by I' = I + Ip where Ip is the inertia of a fictitious point mass of mass mtot (the total body mass) located at p, about CF. Cost is 20 flops.

inline 
Assuming that the current inertia I is a central inertia (that is, it is inertia about the body center of mass CF), shift it to some other point p measured from the center of mass.
This produces a new inertia I' about the point p given by I' = I + Ip where Ip is the inertia of a fictitious point mass of mass mtot (the total body mass) located at p, about CF. Cost is 20 flops.

inline 
Return a new inertia matrix like this one but reexpressed in another frame (leaving the origin point unchanged).
Call this inertia matrix I_OF_F, that is, it is taken about the origin of some frame F, and expressed in F. We want to return I_OF_B, the same inertia matrix, still taken about the origin of F, but expressed in the B frame, given by I_OF_B=R_BF*I_OF_F*R_FB where R_FB is the rotation matrix giving the orientation of frame B in F. This is handled here by a special method of the Rotation class which rotates a symmetric tensor at a cost of 57 flops.

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

inline 
Reexpress this inertia matrix in another frame, changing the object in place; see reexpress() if you want to leave this object unmolested and get a new one instead.
Cost is 57 flops.

inline 
Rexpress in place using an inverse rotation to avoid having to convert it.

inline 

inline 
This is an implicit conversion to a const SymMat33.

inline 
Obtain a reference to the underlying symmetric matrix type.

inline 
Expand the internal packed representation into a full 3x3 symmetric matrix with all elements set.

inline 
Obtain the inertia moments (diagonal of the Inertia matrix) as a Vec3 ordered xx, yy, zz.

inline 
Obtain the inertia products (offdiagonals of the Inertia matrix) as a Vec3 with elements ordered xy, xz, yz.

inline 

inline 

inline 

inline 
Compare this inertia matrix with another one and return true if they are close to within a default numerical tolerance.
Cost is about 30 flops.

inline 
Compare this inertia matrix with another one and return true if they are close to within a specified numerical tolerance.
Cost is about 30 flops.

inlinestatic 
Test some conditions that must hold for a valid Inertia matrix.
Cost is about 25 flops.

inlinestatic 
Create an Inertia matrix for a point located at the origin – that is, an allzero matrix.

inlinestatic 
Create an Inertia matrix for a point of a given mass, located at a given location measured from the origin of the implicit F frame.
This is equivalent to m*crossMatSq(p) but is implemented elementwise here for speed, giving a cost of 14 flops.

inlinestatic 
Create a UnitInertia matrix for a unit mass sphere of radius r centered at the origin.

inlinestatic 
Unitmass cylinder aligned along z axis; use radius and halflength.
If r==0 this is a thin rod; hz=0 it is a thin disk.

inlinestatic 
Unitmass cylinder aligned along y axis; use radius and halflength.
If r==0 this is a thin rod; hy=0 it is a thin disk.

inlinestatic 
Unitmass cylinder aligned along x axis; use radius and halflength.
If r==0 this is a thin rod; hx=0 it is a thin disk.

inlinestatic 
Unitmass brick given by halflengths in each direction.
One dimension zero gives inertia of a thin rectangular sheet; two zero gives inertia of a thin rod in the remaining direction.

inlinestatic 
Alternate interface to brick() that takes a Vec3 for the half lengths.

inlinestatic 
Unitmass ellipsoid given by halflengths in each direction.

inlinestatic 
Alternate interface to ellipsoid() that takes a Vec3 for the half lengths.

inlineprotected 

inlineprotected 

inlineprotected 

related 
Add two compatible inertia matrices, meaning they must be taken about the same point and expressed in the same frame.
There is no way to verify compatibility; make sure you know what you're doing. Cost is 6 flops.

related 
Subtract from one inertia matrix another one which is compatible, meaning that both must be taken about the same point and expressed in the same frame.
There is no way to verify compatibility; make sure you know what you're doing. Cost is 6 flops.
Multiply an inertia matrix by a scalar.
Cost is 6 flops.
Multiply an inertia matrix by a scalar.
Cost is 6 flops.
Multiply an inertia matrix by a scalar given as an int.
Cost is 6 flops.
Multiply an inertia matrix by a scalar given as an int.
Cost is 6 flops.
Divide an inertia matrix by a scalar.
Cost is about 20 flops (one divide and six multiplies).
Divide an inertia matrix by a scalar provided as an int.
Cost is about 20 flops (one divide and six multiplies).
Multiply an inertia matrix I on the right by a vector w giving the vector result I*w.
Compare two inertia matrices for exact (bitwise) equality.
This is too strict for most purposes; use Inertia::isNumericallyEqual() instead to test for approximate equality. Cost here is 6 flops.

related 
Output a humanreadable representation of an inertia matrix to the indicated stream.

protected 