Sign in to follow this  

Center of Mass Question

This topic is 3865 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

So I am programming a 3D physics engine and I have a question about which way I should determine the center of mass of a body. Background info: I handle bodies as a collection of shapes, and each shape has its own mass, mu, e, inertia tensor, etc.. Which way should I do this? 1. center of mass is the "position" of a body in world coordinates. When shapes are added to the body, they are positioned in body coordinates. The center of mass does not change. The problem with this is that its not the most accurate way to do things (the center of mass is not where it should be). But, it is easy to do and makes it easier for the user to superimpose visuals on top of bodies. 2. center of mass is the "position" of a body in world coordinates. When shapes are added to the body, the center of mass of the body is calculated and the body's world "position" is moved relative to the center of mass vector (transformed into world coordinates of course). The shapes in body coordinates are translated by the negative center of mass. The effect of this is that the shapes appear stationary, while the center of mass moves. This option is much more realistic but I worry that it will make actual use of the engine harder. This is because the "position" of the body moves around as shapes are added, making it hard to synchronize visuals. A solution to this problem is that I could have 2 positions for a body, one of its visual position (the one used by the user, doesn't change relative to the center of mass (except when adding a shape)) and another for its center of mass (used by the physics engine for calculations). The disadvantage is that this could be tricky, especially in keeping track of the visual position (performing the necessary transformations relative to the center of mass). what do you guys think about this?

Share this post


Link to post
Share on other sites
I think each object should have its own meaningful center (for positioning purposes) and a calculated center of mass for physics purposes. This would allow for accurate physics and prevent weird bugs, like objects moving when their CM changes. I don't think transformations or rotations should be a problem, as it should be clear in each case which center they involve. Physics calcs always use the CM, object placement uses the meaningful center position.

Share this post


Link to post
Share on other sites
What's wrong with using both?

Each object and object-component has a position, a mass, and a centre of mass. When you attach the components, you recalculate the object's COM by weighted-averaging the component COMs; and the position by whatever fits best.

Admiral

Share this post


Link to post
Share on other sites

This topic is 3865 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this