Given the vertices of a convex polytope, calculate its centroid

448 Views Asked by At

I would like to calculate the centroid (center of mass in case of homogeneous materials) of a convex polytope (equivalent of polyhedron in $n-$dimensional space). The vertices are given and I can use a general programming language (without special mathematical libraries) for this purpose. I outlined the following concept:

(1) Divide the polytope into mutually exclusive and collectively exhaustive simplices (equivalent of tetrahedron in n-dimensional space) the following way:
(1.1) Take any of the vertices.
(1.2) Find $n$ (count of dimensions of the space) neighbouring vertices (if there are more, it does not matter which ones).
(1.3) Process the simplex determined by these $n+1$ points.
(1.4) Remove the vertex chosen in 1.1 from the set.
(1.5) Continue with any other vertex (taking one of those found in 1.2 improves efficiency, however, since you will have to find only one additional neighbouring vertex).
(1.6) When only n+1 vertices are left, it is the last simplex; and after it you have covered the whole polytope.
(2) Calculate the volume of the simplex with the formula: $\frac{\det \begin{bmatrix} v_{0} & \cdots & v_{n} \\ 1 & \cdots & 1 \end{bmatrix}}{n!}$
(3) Calculate the centroid of the simplex with the formula: $\frac{\sum_{i=0}^{n} v_{i}}{n+1}$
(4) Calculate an average from the values produced in 3 using the values received in 2 as weights.

Based on a $2-$dimensional pilot this may work, however, imagining things in n-dimensional space is not my strength.

Does this method determine the centroid?

Is there a simpler or faster one (the number of vertices is a few thousand)?

1

There are 1 best solutions below

2
On BEST ANSWER

This method fails in three dimensions and higher.

Consider a regular octahedron. Choose a vertex. (By symmetry, it makes no difference which one you choose.) This vertex has four neighbors. Choose three of them. (Again by symmetry, it makes no difference which ones you choose.)

The four vertices (your original choice plus the three neighbors) determine a tetrahedron. If you remove the interior of this tetrahedron from the interior of the octahedron, what is left is the interior of a non-convex polyhedron.

What your algorithm does in step 1.4 is to remove not only the volume of the selected tetrahedron, but also the volume of the tetrahedron formed by your original chosen point, the neighbor that you did not choose, and the two common neighbors of these two points. All that is left is a square pyramid.

If your next choice is a vertex on the base of the pyramid (as it will be if you choose the next vertex by "taking one of those found in 1.2"), you will end up processing all of the volume of the pyramid, but since you missed the volume of a tetrahedron you will find the centroid of the non-convex polyhedron formed by the three tetrahedra you processed, not the center of the octahedron.

If your next choice is the apex of the pyramid, you will process only one more tetrahedron and will lose the volume of the remaining part of the pyramid when you delete the apex. You will reach step 1.6 because only four vertices are left, but actually they are four vertices of a square, not four vertices of a tetrahedron.

The idea of "taking one of those found in 1.2" does not work as expected, however, because the original $n$ neighbors of the first vertex are not always neighbors of each other.


You can find the centroid of the polytope by partitioning it into simplexes and taking a weighted average of their centroids using the formulas in the question. But you will need to ensure that the simplexes and their interiors contain the entire polytope and its interior and that there are no two simplexes whose interiors intersect.