# How to get a list of vertices in a convex hull

I have the following convex hull:

X = {{0, 0, 0}, {0, 0, 0.285957}, {0, 0.285957, 0.285957}, {0, 0.381238,
0.190619}, {0, 0.571914, 0}, {0.190676, 0.381238,
0.190619}, {0.285957, 0.285957, 0.285957}, {0.571914, 0,
0}, {0.571914, 0, 0.285957}}

ConvexHullMesh[X, Axes -> True, AxesLabel -> {a1, a2, a3},
Boxed -> True, PlotTheme -> "Monochrome",
ViewPoint -> {-1.6717420364862037, 2.6135645953045867,
1.3507622550305927}]


which plots,

I would like to find a matrix with the vertice number of each side of the hull. For example

0   0   0 -> is 0
0   0   0.285957 -> is 1
0   0.285957    0.285957 -> is 2
0   0.3812378724    0.1906189362 -> is 3
0   0.571914    0 -> is 4
0.1906761276    0.3812378724    0.1906189362 -> is 5
0.285957    0.285957    0.285957 -> is 6
0.571914    0   0 -> is 7
0.571914    0   0.285957 -> is 8


each row in the following matrix corresponds with a side of the convex hull,

8 7 0 1 8
7 8 6 4 7
4 2 1 0 4
6 8 1 2 6
4 6 2 4 4
4 7 0 4 4


How could I get this last matrix number from a set of coordinates X?.

• What do you mean by "patch"? – Henrik Schumacher Jun 5 '18 at 22:07

I do not really understand what you mean by "patch" but of you look for the (triangle) face index lists of the convex hull in terms of the original vertices, this should work:

R=ConvexHullMesh[X];
Range[MeshCellCount[R, 0]],
Flatten[Nearest[X -> Automatic, MeshCoordinates[R]]]
];
faces = Partition[
Lookup[
lookuptable,
Flatten[MeshCells[R, 2, "Multicells" -> True][[1, 1]]]
],
3
]

• Edited. Please try again. Note that I can't see any pentagons as sides of the convex hull. – Henrik Schumacher Jun 5 '18 at 22:32
• Thank you for your answer. I call patch to each side of the convex hull. The code of your post works for me. I only would need to start numbering from 0 not from 1, and to close the polygon` or to add the first vertex to the end of the list of vertices. For example, {1,5,8} should be { 0,4,7,0}. Is it that possible to make?. – user1993416 Jun 5 '18 at 22:41
• I do not know why Mathematica uses two triangles to form a side with four vertices. This procedure will give more sides than the real figure. Is it possible to get a matrix of vertices like in the example, and use the number of vertices of the side with the highest number of vertices and repeating the first vertex at the end of the row to close the polygon? – user1993416 Jun 5 '18 at 22:54
• Mathematica uses the external library TetGen for computing convex hulls of point clouds in three dimensions. And TetGen uses tetrahedra and triangles to build geometric objects. That's actually a very good idea since all polyhedral structures can be build from that and it holds the combinatorical complexity at bay. – Henrik Schumacher Jun 6 '18 at 6:46
• I am going to post the problem in a new question – user1993416 Jun 6 '18 at 8:13