Wolfram Research

Function Repository Resource:

ConvexHullMeshGraphicsComplex (1.0.0) current version: 1.0.1 »

Source Notebook

Return a GraphicsComplex for ConvexHullMesh

Contributed by: Ed Pegg Jr

ResourceFunction["ConvexHullMeshGraphicsComplex"][pts]

returns the convex hull of pts in the GraphicsComplex format.

Examples

Basic Examples (2) 

Return the GraphicsComplex of a square:

In[1]:=
gc2 = ResourceFunction["ConvexHullMeshGraphicsComplex"][
  Tuples[{-1, 1}, {2}]]
Out[1]=

Show it:

In[2]:=
Graphics[gc2, ImageSize -> Tiny]
Out[2]=

Return the GraphicsComplex of a cube:

In[3]:=
gc3 = ResourceFunction["ConvexHullMeshGraphicsComplex"][
  Tuples[{-1, 1}, {3}]]
Out[3]=

Show it:

In[4]:=
Graphics3D[gc3, ImageSize -> Tiny]
Out[4]=

Neat Examples (2) 

Show the biggest known little polyhedron on 16 points with all unit length diagonals shown in red:

In[5]:=
tetrahedralGroup = {{{-1, 0, 0}, {0, -1, 0}, {0, 0, 1}}, {{0, -1, 0}, {0, 0, 1}, {-1, 0, 0}}, {{0, 0, 1}, {-1, 0, 0}, {0, -1, 0}}, {{0, 0, -1}, {1, 0, 0}, {0, -1, 0}}, {{0, 1, 0}, {0, 0, -1}, {-1, 0, 0}}, {{1, 0, 0}, {0, 1, 0}, {0, 0, 1}}, {{0, -1, 0}, {0, 0, -1}, {1, 0, 0}}, {{-1, 0, 0}, {0, 1, 0}, {0, 0, -1}}, {{0, 0, 1}, {1, 0, 0}, {0, 1, 0}}, {{1, 0, 0}, {0, -1, 0}, {0, 0, -1}}, {{0, 0, -1}, {-1, 0, 0}, {0, 1, 0}}, {{0, 1, 0}, {0, 0, 1}, {1, 0, 0}}}; partial16 = Join[# . {r, r, 1/2 Sqrt[1 - 4 r^2]} & /@ tetrahedralGroup, 1/6 (4 r + Sqrt[1 - 4 r^2] - (
      Sqrt[2] Sqrt[(-1 + 8 r^2)^2 (5 + 4 r Sqrt[1 - 4 r^2])])/(
      1 - 8 r^2)) {{1, 1, 1}, {1, -1, -1}, {-1, 1, -1}, {-1, -1, 1}}] /. {r -> Root[71289 - 5627392 #1^2 + 144921856 #1^4 - 1690055680 #1^6 + 9926729728 #1^8 - 31050825728 #1^10 + 55221420032 #1^12 - 67570237440 #1^14 + 58284048384 #1^16 &, 5]};
diag = Select[Subsets[Range[16], {2}], Chop[(1 - ( EuclideanDistance @@ N[partial16[[#]]]))] == 0 &];
Graphics3D[{Opacity[.5], ResourceFunction["ConvexHullMeshGraphicsComplex"][partial16], Red, Opacity[1], Tube[partial16[[#]]] & /@ diag}, Boxed -> False, SphericalRegion -> True]
Out[7]=

ConvexHullMesh also works in this case:

In[8]:=
Graphics3D[{Opacity[.5], ConvexHullMesh[partial16], Red, Opacity[1], Tube[partial16[[#]]] & /@ diag}, Boxed -> False, SphericalRegion -> True]
Out[8]=

Version History

  • 1.0.1 – 29 November 2022
  • 1.0.0 – 28 November 2022

Author Notes

ConvexHullMesh[pts]["GraphicsComplex"] was deprecated in version 12. Said function option was used in many Wolfram Demonstrations, so this function is a fix for those.

License Information