Jolt Physics
A multi core friendly Game Physics Engine
Loading...
Searching...
No Matches
MassProperties Class Reference

Describes the mass and inertia properties of a body. Used during body construction only. More...

#include <MassProperties.h>

Public Member Functions

bool DecomposePrincipalMomentsOfInertia (Mat44 &outRotation, Vec3 &outDiagonal) const
 
void SetMassAndInertiaOfSolidBox (Vec3Arg inBoxSize, float inDensity)
 Set the mass and inertia of a box with edge size inBoxSize and density inDensity.
 
void ScaleToMass (float inMass)
 Set the mass and scale the inertia tensor to match the mass.
 
void Rotate (Mat44Arg inRotation)
 Rotate the inertia by 3x3 matrix inRotation.
 
void Translate (Vec3Arg inTranslation)
 Translate the inertia by a vector inTranslation.
 
void Scale (Vec3Arg inScale)
 Scale the mass and inertia by inScale, note that elements can be < 0 to flip the shape.
 
void SaveBinaryState (StreamOut &inStream) const
 Saves the state of this object in binary form to inStream.
 
void RestoreBinaryState (StreamIn &inStream)
 Restore the state of this object from inStream.
 

Static Public Member Functions

static Vec3 sGetEquivalentSolidBoxSize (float inMass, Vec3Arg inInertiaDiagonal)
 Calculates the size of the solid box that has an inertia tensor diagonal inInertiaDiagonal.
 

Public Attributes

float mMass = 0.0f
 Mass of the shape (kg)
 
Mat44 mInertia = Mat44::sZero()
 Inertia tensor of the shape (kg m^2)
 

Detailed Description

Describes the mass and inertia properties of a body. Used during body construction only.

Member Function Documentation

◆ DecomposePrincipalMomentsOfInertia()

bool MassProperties::DecomposePrincipalMomentsOfInertia ( Mat44 outRotation,
Vec3 outDiagonal 
) const

Using eigendecomposition, decompose the inertia tensor into a diagonal matrix D and a right-handed rotation matrix R so that the inertia tensor is \(R \: D \: R^{-1}\).

See also
https://en.wikipedia.org/wiki/Moment_of_inertia section 'Principal axes'
Parameters
outRotationThe rotation matrix R
outDiagonalThe diagonal of the diagonal matrix D
Returns
True if successful, false if failed

◆ RestoreBinaryState()

void MassProperties::RestoreBinaryState ( StreamIn inStream)

Restore the state of this object from inStream.

◆ Rotate()

void MassProperties::Rotate ( Mat44Arg  inRotation)

Rotate the inertia by 3x3 matrix inRotation.

◆ SaveBinaryState()

void MassProperties::SaveBinaryState ( StreamOut inStream) const

Saves the state of this object in binary form to inStream.

◆ Scale()

void MassProperties::Scale ( Vec3Arg  inScale)

Scale the mass and inertia by inScale, note that elements can be < 0 to flip the shape.

◆ ScaleToMass()

void MassProperties::ScaleToMass ( float  inMass)

Set the mass and scale the inertia tensor to match the mass.

◆ SetMassAndInertiaOfSolidBox()

void MassProperties::SetMassAndInertiaOfSolidBox ( Vec3Arg  inBoxSize,
float  inDensity 
)

Set the mass and inertia of a box with edge size inBoxSize and density inDensity.

◆ sGetEquivalentSolidBoxSize()

Vec3 MassProperties::sGetEquivalentSolidBoxSize ( float  inMass,
Vec3Arg  inInertiaDiagonal 
)
static

Calculates the size of the solid box that has an inertia tensor diagonal inInertiaDiagonal.

◆ Translate()

void MassProperties::Translate ( Vec3Arg  inTranslation)

Translate the inertia by a vector inTranslation.

Member Data Documentation

◆ mInertia

Mat44 MassProperties::mInertia = Mat44::sZero()

Inertia tensor of the shape (kg m^2)

◆ mMass

float MassProperties::mMass = 0.0f

Mass of the shape (kg)


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