0 votes

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?

Godot version 3.5.1
in Engine by (138 points)

1 Answer

+2 votes

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.globaltransform.origin * Rigid1.mass) + (Rigid2.globaltransform.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

by (138 points)
Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.