0

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,

enter image description here

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?.

user1993416
  • 589
  • 1
  • 5
  • 12

1 Answers1

1

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];
lookuptable = AssociationThread[
   Range[MeshCellCount[R, 0]],
   Flatten[Nearest[X -> Automatic, MeshCoordinates[R]]]
   ];
faces = Partition[
  Lookup[
   lookuptable,
   Flatten[MeshCells[R, 2, "Multicells" -> True][[1, 1]]]
   ],
  3
  ]
Henrik Schumacher
  • 106,770
  • 7
  • 179
  • 309
  • Edited. Please try again. Note that I can't see any pentagons as sides of the convex hull. – Henrik Schumacher Jun 05 '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 05 '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 05 '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 06 '18 at 06:46
  • You can "close" the the index triples in the list faces from above by closedfaces = Join[faces, faces[[All, {1}]], 2]. – Henrik Schumacher Jun 06 '18 at 06:48
  • The code is beautiful. I understand why Mathematica uses triangles. Thank you very much. – user1993416 Jun 06 '18 at 07:43
  • You're welcome. – Henrik Schumacher Jun 06 '18 at 07:45
  • I would like to get the vertices of the sides of the hull without the edges of the triangles that are in the same plane. Do you know how I could get the close removing connections of vertices in the same plane or side of the figure? – user1993416 Jun 06 '18 at 07:55
  • 1
    I am going to post the problem in a new question – user1993416 Jun 06 '18 at 08:13