Tesselation or discretization of arbitrary 2D planar shapes is a common problem in finite element analysis. It's commonly done with planar triangles or quadrilaterals. Try a Google search on "2d finite element mesh generation" or quadtree or octree mesh generation. You can calculate the centroid of each simple shape and apply the (correct) formula that you cited.
Something like this. Or these. You'd have to supply the raw geometry for the body in question, of course.
You've a long row to hoe yet. You'll have to do all of the following:
- Find an auto meshing program and learn how to input the geometry for your 2D shape.
- Run the auto mesher and get a mesh output which will consist of all the 2D points in space and the connectivities of all the triangular and quadrilateral elements.
- Write a program to read in the mesh and calculate the area and centroid of each element.
- Plug those values into the formula you cited to calculate the centroid of your original 2D shape. This means looping over all the elements and accumulating the areas an the products of the (x,y) coordinates of each element centroid and its area.
- Once you have an answer, you need to check convergence. You do this by refining your mesh by making the elements smaller and recalculating. You know you've converged when you refine the mesh and the answers change by less than a small tolerance (5% or whatever you're willing to tolerate).
It's still a fair amount of work.
UPDATE: This one looks quite good, and it's open source.