Skip to main content

rigid_body_mass_properties

The mass properties of a rigid-body is composed of three parts:

  • The mass which determines the resistance of the rigid-body wrt. linear movements. A high mass implies that larger forces are needed to make the rigid-body translate.
  • The angular inertia determines the resistance of the rigid-body wrt. the angular movements. A high angular inertia implies that larger torques are needed to make the rigid-body rotate.
  • The center-of-mass determines relative to what points torques are applied to the rigid-body.
note

Zero is a special value for masses and angular inertia. A mass equal to zero is interpreted as an infinite mass. An angular inertia equal to zero is interpreted as an infinite angular inertia. Therefore, a rigid-body with a mass equal to zero will not be affected by any force, and a rigid-body with an angular inertia equal to zero will not be affected by any torque.

Computing the mass and angular-inertia can often be difficult because they depend on the geometric shape of the object being simulated. This is why they are automatically computed by Rapier when a collider is attached to the rigid-body: the collider add its own mass and angular-inertia contribution (computed based on the collider's shape and density) to the rigid-body it is attached to:

<load path='/2d/rust/examples/rs_rigid_bodies2.rs' marker='Mass1' />
<load path='/2d/bevy/examples/rigid_bodies2.rs' marker='Mass1' />
<load path='/2d/javascript/src/snippets/rigid_bodies.ts' marker='Mass1' />

Alternatively, it is possible to set the mass properties of a rigid-body when it is created. Keep in mind that this won't prevent the colliders' contributions to be added to these values. So make sure to set the attached colliders' densities to zero if you want your explicit values to be the final mass-properties values.

<load path='/2d/rust/examples/rs_rigid_bodies2.rs' marker='Mass2' />
<load path='/2d/rust/examples/rs_rigid_bodies2.rs' marker='Mass3' />
<load path='/2d/bevy/examples/rigid_bodies2.rs' marker='Mass2' />
<load path='/2d/bevy/examples/rigid_bodies2.rs' marker='Mass3' />
<load path='/2d/javascript/src/snippets/rigid_bodies.ts' marker='Mass2' />