# NewtonBodySetMassMatrix

## NewtonBodySetMassMatrix

void NewtonBodySetMassMatrix( const NewtonBody* bodyPtr, dFloat mass, dFloat Ixx, dFloat Iyy, dFloat Izz)


## Usage

Set the mass matrix of a rigid body.

## Parameters

• const NewtonBody *bodyPtr - pointer to the body.
• dFloat mass - mass value.
• dFloat Ixx - moment of inertia of the first principal axis of inertia of the body.
• dFloat Iyy - moment of inertia of the first principal axis of inertia of the body.
• dFloat Izz - moment of inertia of the first principal axis of inertia of the body.

• Nothing.

## Description

This function is used to set the mass and the moment of inertia every time a new body is created in Newton. The mass dictates how 'hard' it is to move a body, or how much force is needed to accelerate it. The classic formula NaodW29-math161d54395c79908c00000001 is an example of this. The moment of inertia (Ixx, Iyy, Izz) is harder to understand, they describe how hard it is to rotate a body.

For realistic physics these values need to be set sensibly. Here are some simple formulae for uniform density shapes:

These are right but you'll have to read latex for now :(
(Tip - If the math looks like garbage, click 'edit' so see the source, and 'cancel' when you're done.)

• Solid Sphere Ixx = Iyy = Izz = \frac{2*radius^2*mass}{5}
• Solid Box Ixx = mass * (ly*ly + lz*lz) / 12 Iyy = mass * (lx*lx + lz*lz) / 12 Izz = mass * (lx*lx + ly*ly) / 12
• Solid Cylinder Ixx = Iyy = mass * ( \frac{radius^2}{4} + \frac{1}{12}) * height^2 Izz = mass * radius^2 / 2

To make an object unmovable (static, infinite mass) either set the mass to below 0.001f (it is best to set it to 0.0f) or do not call the function (as the object will default to static). When static, an object's force and position callbacks are not called.

## Remarks

• Newton algorithms have no restriction on the values for the mass, but due to floating point dynamic range (24 bit precision) it is best if the ratio between the heaviest and the lightest body in the scene is limited to 200. There are no special utility functions in Newton to calculate the moment of inertia of common primitives. The application should specify the inertial values, keeping in mind that realistic inertia values are necessary for realistic physics behavior.