The moment of inertia is additive like mass.

Here's a nice verbose example in C:

- Code: Select all
`// offset of the weights`

cpFloat offset = 10.0f;

// centers of the weights

cpVect center1 = cpv( offset, 0.0f);

cpVect center2 = cpv(-offset, 0.0f);

cpFloat mass = 1.234;

cpFloat radius = 3.0f;

cpFloat moment = cpMomentForCircle(mass/2.0f, 0.0f, radius, center1) + cpMomentForCircle(mass/2.0f, 0.0f, radius, center2);

cpBody *body = cpBodyNew(mass, moment);

cpShape *shape1 = cpCircleShapeNew(body, radius, center1);

cpShape *shape2 = cpCircleShapeNew(body, radius, center2);

cpShape *shape3 = cpSegmentShapeNew(body, center1, center2);

The moment of inertia for both circles will actually be identical, as the offset distance is the same. In this case, you could simplify the moment to:

- Code: Select all
`cpFloat moment = cpMomentForCircle(mass, 0.0f, radius, center1);`

I left out the moment of the segment. You don't really need it as it will make a pretty small difference. The bar isn't going to weigh much, and then you need to figure out how to split up the mass. Another thing to keep in mind is that these functions are really only helping you estimate the moment. As long as you are within a few factors of the correct number, people won't really notice and stability won't suffer.