if I have the coordinates of the vertices of an irregular plane polygon, how do I find the position of its centre of gravity ?
Look at
http://astronomy.swin.edu.au/~pbourke/geometry/polyarea/
near the bottom of the page.
--Graeme
Graeme, why does the formula give us the center of gravity. How
did someone derive this formula?
Yatir
It works by dividing the polygon into triangles (in a very
strange way, which I'll talk about in a minute) finding the
centroids (i.e. center of gravity) of all the triangles and then
takes the weighted average of these centroids.
Now, for the strange way of dividing the polygon into triangles...
First, I'll define "signed area" of a triangle with vertices
(x1,y1),(x2,y2),(x3,y
3) as
(1/2)(x1y2-x2y1+x2y
3-x3y2+y1x3-x
1y3)
If the vertices are named counterclockwise, the area is positive,
and the area is negative if the vertices are named clockwise.
Let P1, P2, ..., Pn be the vertices of the polygon. The strange way
we divide this polygon into triangles is by adding an n+1th point,
which I'll call O, and making n stangely overlapping triangles as
follows:
P1, P2, O
P2, P3, O
...
Pn, P1, O
After a little thought, and some picture-drawing, you'll see that
the signed area of these n triangles is equal to the area of the
polygon. When you add up the areas of the triangles, you'll see
that the coordinates of point "O" cancel out entirely, making it
irrelevant where that point is. If point "O" is chosen to be the
origin, then the area of each triangle is a function of the
coordinates of the other two points, making the sum very easy to
calculate.
The centroid of a triangle is simply the average of the three
corners, so the formula adds up the centroid multiplied by the area
of each triangle, and divides the result by the area of the whole
polygon.
The number "6" in the denominator comes from the fact that the
centriod of the triangle is the average of three numbers and the
area of each triangle has a factor of (1/2) in the formula.