Center of gravity of a self intersecting irregular polygon I am trying to calculate the center of gravity of a polygon.
My problem is that I need to be able to calculate the center of gravity for both regular and irregular polygons and even self intersecting polygons.
Is that possible?
I've also read that: http://paulbourke.net/geometry/polyarea/ But this is restricted to non self intersecting polygons.
How can I do this? Can you point me to the right direction?
Sub-Question: Will it matter if the nodes are not in order? if for example you have a square shape and you name the top right point (X1Y1) and then the bottom right point (X3Y3)?
In other words if your shape is like 4-1-2-3 (naming the nodes from left to right top to bottom)
Note: Might be a stupid question but I'm not a maths student or anything!
Thanks

If you are given just a list of points $z_i=(x_i, y_i)$ $\>(1\leq i\leq n)$ then it is not immediate how these points should determine a certain polygon. Maybe you want the convex hull $C$ of these points. There are algorithms that accept your list as input and produce a second list $(w_i)_{1\leq i\leq m}$ (a subset of the $z_i$) containing the corners of $C$ in counter-clockwise order. Using this second list you can compute the area and centroid of $C$ by means of the formulas given in the quoted source.
These formulas come from an application of Green's theorem to $C$ and its boundary $\partial C$. It reads as follows:
$${\rm area}(C)={1\over2}\int_{\partial C}(x\,dy- y\,dx).$$
If you apply this formula to an arbitrary closed curve, as, e.g., the piecewise linear curve $\gamma$ determined by the original $z_i$ you get very strange results: Every part enclosed by $\gamma$ is counted as many times as it is surrounded counterclockwise by $\gamma$.
