# Total angular velocity of multiple bodies

1. Nov 9, 2014

### faiface

Hello,

this is a question regarding planar physics. Suppose we have multiple bodies. We can ignore their individual shape and angular speed. So every body is represented by it's position, mass and moment of inertia about it's center of mass.
Now my question is, how to calculate the moment of inertia, angular momentum and angular velocity of all of these bodies together about their common center of mass?
I've got something going, but it's not working as expected.

Last edited: Nov 9, 2014
2. Nov 9, 2014

### Staff: Mentor

Find the center of mass, calculate the contribution of each object, sum all together (this won't give an angular velocity as different objects have a different one), but a total angular momentum).
Then it would help if you show that.

3. Nov 9, 2014

### faiface

Ok, here's the pseudocode of what I've got (I can calculate the center of mass no problem):

totalInertia = 0;
totalAngMomentum = 0;
for (body: bodies) {
distance = dst(body.getPosition(), centerOfMass);
inertia = body.getInertia() + body.getMass() * distance^2;
ang_vel = body.getLinearVelocity().dot(normalize(body.getPosition() - centerOfMass).rotate(PI/2)) / distance;
totalInertia += inertia;
totalAngMomentum += inertia * ang_vel;
}
angVelocity = totalAngMomentum / totalInertia;

4. Nov 9, 2014

### Staff: Mentor

Your code assumes that they are rotating with the angular velocity you calculate for the net motion. Is that intended?

And what is going wrong?

5. Nov 9, 2014

### faiface

Oh, the whole problem was, that I was calculating with the absolute linear velocity of a body instead of relative to the velocity of the center of mass. So yeah, it was not intended :). Thank you very much for your help and patience!