# Center of mass

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

## Recommended Posts

Does anyone know an easy way to find the center of mass for a 2d polygon? I thought maybe finding the average of the points, but weighting the points for how far apart the lines are... Thanks!

##### Share on other sites
there was a thread on this just days ago.

##### Share on other sites
If you need to calculate the centroid of flat polygon, one sipmle way is to

1) first triangulate it
2) then, each triangle has it's area (evaluated simply by half modulo of sideds vector product) and it's mass center (point of medians intersection)
3) now, we treat everu triangle in triangulation as point in triangle mass center with mass of triangle area
4) then simply find the weighted average of this points, as mentioned in link above

GL!

##### Share on other sites
for triangles and quads, take the average of each of it's vertices, this will give you the gemoetric center, which is the center of mass provided the density is constant, if it's not constant you would have to anlitically integrate it, you could

a) IF your surface is easily paramterizable
use numarical integration
b) If your surface is NOT easily paramaterizable,
use monte carlo integration

both of these methods are definitly off line approaches.

monte carlo integration with stratified sampling would be a more efficent approach then Jackis method as it would not require triangulation his method as far as I can see, which would still require integration of the subdomains(triangles) to be correct.

Tim

[Edited by - timw on September 7, 2005 11:58:47 PM]

##### Share on other sites
No, my method doesn't require integration of subdomains, cause subdomains are simple triangles, so, it only represents subdomains as weighted points, evaluated simply, center of mass remains the same.
Triangulation is needed, yes, but Monte-Carlo method has some lacks, like it is numerical and not exact, and it must check each new point for intersection with polygon (it takes O(n), where n is the number of polygon edges in general case, sure, it may be optimized). Triangulation costs N*logN (ear triangluation), and it is done once per polygon.

Sorry, may be, I didn't understand you right, because of translation difficulties )))

##### Share on other sites
I was talking about the case of non constant density, which I think you weren't sorry. if the density is non constant, triangluation wont work, but looking back it looks like you were only talking about uniform density case, sorry.

Tim

##### Share on other sites
No need to be sorry, I was talking about uniform density but I may implement non uniform density... Thanks all!

##### Share on other sites
timw

You're absolutely right, my proposed method will solve the problem only in a case of uniform density.
When it becomes varying, the thing you proposed will be the most comfortable way to solve the problem.

Thanks for this little fix! I forgot to mention density uniformness.

• ### What is your GameDev Story?

In 2019 we are celebrating 20 years of GameDev.net! Share your GameDev Story with us.

• 15
• 9
• 11
• 9
• 9
• ### Forum Statistics

• Total Topics
634135
• Total Posts
3015754
×