• ### What is your GameDev Story?

#### Archived

This topic is now archived and is closed to further replies.

# Center of mass of 2D figures?

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

## Recommended Posts

I was thinking about it, and, how do you find CM of a 2D figure (any amount of sides, all internal angles < 180, mass is spread uniformly) ? I was thinking, maybe it''s the point that if you connect it with all the corners of the figure, you''ll get equal lengths? Am I correct? if so, how to easily find such point?

##### Share on other sites
I''m not saying anything for sure (it''s still early in the morning) but :

o The center of mass G has the property that the integral of MG*ρ dV where M is a point in the object, dV is the amount of volume around M, and ρ the mass per volume.

o The center of mass G has coordinates OG. But m * OG is equal to the integral of OG*ρ dV (where m is the total mass).

o This, by replacing OG by OM + MG, and by exploiting the null-ness of the above integral, is equal to the integral of OM*ρ dV.

Now all you need to do is compute the latter integral (you''ll get a vector), divide that vector by m, and you''ll get the OG vector (and your G point)

o To do this, remember that you can split up your above integral into integrals over smaller volumes (triangles). The total integral will be equal to the sum of the smaller ones.

o You know how to compute the integral over a triangle : its the integral of OM, which is equal to the integral of OG'' over that triangle (where G'' is the center of gravity of that triangle).

o You also know how to turn any polygon into triangles.

So the final method is :

o Cut the polygon into triangles T1 ... Tn, of total masses m1 ... mn, equal to the total area divided by the triangle area, times the total mass of the entire polygon.

o Compute the centers of gravity G1 ... Gn of the triangles (add together the coordinates of the corners, and divide by 3)

o Add together all m1 OG1 ... mn OGn (vector times mass of triangle), and divide by m (total mass).

And there, you got your center of gravity. Don''t trust me, I''m half asleep, the other half being sleepy.

Victor Nicollet, INT13 game programmer

##### Share on other sites
If you suppose, in addition, that the polygon is convex (which as I''ve just noticed, you actually do), then it becomes even easier, since the triangulation is trivial and you can write right away that :

OG = 1/N * sumi=0NOMi

Where OM1 ... OMN are the corners of the figure.

Victor Nicollet, INT13 game programmer

• ### What is your GameDev Story?

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

• 9
• 34
• 16
• 11
• 11
• ### Forum Statistics

• Total Topics
634122
• Total Posts
3015646
×