Given a set of 2d points we can find it's convex hull.
Now I'm going to explain an algorithm I thought of and you guys let me know where I've gone wrong (because it probably is wrong)
So our goal is to calculate the center of mass.
Split up the polyhedron into n-1 quadrilateral, where n is the number of points that are not extremums or the X axis. The quadrilateral should have 2 sides along the Y axis (you should be able to use any 2 perpendicular axis and this should work fine).
Now (unless I'm wrong) it's very easy to calculate the center of mass of each of these quadrilaterals (or triangles) individually.
2.1 The center of mass of a triangle is the middle of the 3 vertices divided by 3.
2.2 Any other quadrilateral will have 4, 2 or 0 right angle, if it's 4 then we can do the sum of the vertices divided by 4, and if it's 2 or 0 we can calculate the center of mass by splitting the shape again.
Let's take a random slab for example
I can split that slab into 2 triangle and a square
and for those 3 shapes it's easy to calculate the center of mass. (and the area for that matter)
Next, and I need confirmation on this, can I use the position of the center of mass and it's volume to calculate the center of mass for the entire slab.
Then, once I have all the centers of mass for all the slabs, can I use the same trick again (because I have the position and the volume) to calculate the center of mass of the entire polytope ?
Assuming this all works, would it also work in 3D ?
extra: A little improvement that I thought, is there maybe a relationship that would find the center of mass of one of the slab by taking the center of mass of the 2 parallel lines ?
Because if yes that should also apply when taking the center of mass of 2 parallel convex polyhedra to find the center of mass of the 3d slab ?
edit: In case this actually works, what's the big O complexity of this algorithm ? O(n^2) ?