Center of Mass

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Blockmaster27

Assuming that global_transform.origin is a RigidBody’s static center of mass, how could one find a new center of mass with other objects combined?

Example:

Rigid Body 1 has a mass of 2 and a local origin of Vector3(0, 0, 0)
Rigid Body 2 has a mass of 1 and a local origin of Vector3(0, 0, 1)
Rigid Body 3 has a mass of 12 and a local origin of Vector3(0, 0, -4)

How would you find the weighted centerpoint of these three objects?

:bust_in_silhouette: Reply From: Blockmaster27

For anyone who finds this:

USE THIS SIMPLE EQUATION! Does not account for density, pressure, etc. but it is good enough for a simple static center of mass.

((Rigid1.global_transform.origin * Rigid1.mass) + (Rigid2.global_transform.origin * Rigid2.mass) + (Rigid3.global_transform.origin * Rigid3.mass)) / Rigid1.mass + Rigid2.mass + Rigid3.mass

This will give the combined center of mass of these three objects. Just keep adding for more objects. The equation can be simplified to such: (Vector3 * Mass + Vector3 * Mass) / Total Mass

1 Like