0
$\begingroup$

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

$\endgroup$
1
  • $\begingroup$ What do you mean by "patch"? $\endgroup$ Jun 5, 2018 at 22:07

1 Answer 1

1
$\begingroup$

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
  ]
$\endgroup$
9
  • $\begingroup$ Edited. Please try again. Note that I can't see any pentagons as sides of the convex hull. $\endgroup$ Jun 5, 2018 at 22:32
  • $\begingroup$ 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?. $\endgroup$ Jun 5, 2018 at 22:41
  • $\begingroup$ 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? $\endgroup$ Jun 5, 2018 at 22:54
  • $\begingroup$ 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. $\endgroup$ Jun 6, 2018 at 6:46
  • 1
    $\begingroup$ I am going to post the problem in a new question $\endgroup$ Jun 6, 2018 at 8:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.