Jump to content
  • Advertisement
Sign in to follow this  
badmoon

Centre of Mass of a Polyhedron

This topic is 5476 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

Advertisement
Thanks, but that only gives source code to do this - if I looked at that, I'd feel like I'm cheating! But it should come in handy when I want to verify my own code.
I was wandering if someone was aware of a site that would mathematically explain how to calculate the centre of mass of a polyhedron.
I thought of a method myself: Split the mesh up into pyramids (this should be possible with any mesh (the base of a pyramid can be any trianlge not just an equilateral one)) work out the centre of masses for each pyramid and then get the average of all these centre of masses to get the centre of mass of the polyhedron. However, splitting a mesh into pyramids seems like a rather arduous task to me...

Share this post


Link to post
Share on other sites
Quote:
Original post by badmoon
Thanks, but that only gives source code to do this - if I looked at that, I'd feel like I'm cheating! But it should come in handy when I want to verify my own code.
I was wandering if someone was aware of a site that would mathematically explain how to calculate the centre of mass of a polyhedron.
I thought of a method myself: Split the mesh up into pyramids (this should be possible with any mesh (the base of a pyramid can be any trianlge not just an equilateral one)) work out the centre of masses for each pyramid and then get the average of all these centre of masses to get the centre of mass of the polyhedron. However, splitting a mesh into pyramids seems like a rather arduous task to me...

In fact it's done almost like that, you're right, and this will work(if you'll compute weighted average with masses of piramids as weights).

It's not hard to split into piramids, piramid for every triangle, with point P as fourth point, P is placed somewhere inside your polyhedrom.

And if you assume that with some winding of triangle(clockwise vs counterclockwise) volume of piramid is positive and with opposite winding is negative(negative if face faces P), and your mesh triangles all winded in right direction(like for culling), it must work even if P is outside of polyhedron! Effect of volume that is not inside thing but inside some of piramids is added then subtracted(draw it on paper).

It's also can be done like
For each triangle determine center of mass and mass of volume "between" triangle and it's projection onto some plane(say,z=0) (imagine that sun lights from +z direction, and shadow of triangle it's volume i'm talking about). This volume is kinda like prism.

Note that some prisms created by triangles that faces plane must have "negative" mass.

As you can see, summ of positive/negative mass distribution exactly matches your polyhedron.

Then you compute weighted average(with mass as weight) of centers of masses of prisms, just like with piramids.

edit: typos,rewording.

Share this post


Link to post
Share on other sites
I like the method you suggested for splitting my mesh into pyramids, but that will only work for convex polyhedrons - I cannot gaurantee this property for all my meshes (I'd have to split them up into convex partitions and I don't want to go through that hassle).

The second method you mentioned using 'projected prisms' seems quite ingenious, but will it only work for convex polyhedrons?

A site that would explain all this would be great, if you know of one...

Share this post


Link to post
Share on other sites
Quote:
Original post by badmoon
I like the method you suggested for splitting my mesh into pyramids, but that will only work for convex polyhedrons - I cannot gaurantee this property for all my meshes (I'd have to split them up into convex partitions and I don't want to go through that hassle).

The second method you mentioned using 'projected prisms' seems quite ingenious, but will it only work for convex polyhedrons?

A site that would explain all this would be great, if you know of one...

it must work with non-convex polyhedrons, you will have nonzero resulting mass only inside polyhedron - "negative" masses will do the job.

Share this post


Link to post
Share on other sites
hm just a suggestion

how about getting the center of each triangle/polygon and then get the center of all centers and use this as the center of mass?


its a approximation but i think this should work as well as the pyramid thing

Share this post


Link to post
Share on other sites
Quote:
Original Post by Dmytry
it must work with non-convex polyhedrons, you will have nonzero resulting mass only inside polyhedron - "negative" masses will do the job.


Do you mean the first method will work for non-convex polyhedrons? Because in this case some of your pyramids could partly be inside the mesh and partly not, so if you look at just their positive volume (i.e. the part in the mesh) it's no longer a pyramid but one with 'bits' missing from it - and that just makes another polyhedron so we haven't simplified the problem.

If you meant the 2nd method will work for non-convex polyhedrons, then can you elaborate more on this, because I still can't quite see how this would work

Share this post


Link to post
Share on other sites
Quote:
Original post by Basiror
hm just a suggestion

how about getting the center of each triangle/polygon and then get the center of all centers and use this as the center of mass?


its a approximation but i think this should work as well as the pyramid thing


The pyramid thing is not an approximation. But are you sure this method you suggest is an approximation? 'Cause if it wasn't that would be great. Can you give me an example where this would not work

Share this post


Link to post
Share on other sites
I believe the first method he mentioned will work on all meshes, convex or not. The important thing he stressed was that you have the winding order of the triangles correct, and when you chosen center point tip of the pyramid is on the "inside" of a pyramid's base (determined using the winding order), you count that pyramid as having postive mass, but when your chosen tip is on the "outside" of a pyramid's base, you count that pyramid's mass as negative. In the end, when you sum all the weighted centers together (using negative weights when mass is negative), then I think it will all work out just as it should. I think. I'll let someone else confirm it if they would like, though.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!