DuganHammock/ConvexPolytope

(1.0.0) current version: 1.0.2 »

Compute convex polytopes in n-dimensions

Contributed by: Dugan Hammock

ConvexPolytope[ vertices ] computes the polytope defined by the convex hull of a set of vertices in n-dimensional space.

Installation Instructions

To install this paclet in your Wolfram Language environment, evaluate this code:
PacletInstall["DuganHammock/ConvexPolytope"]


To load the code after installation, evaluate this code:
Needs["DuganHammock`ConvexPolytope`"]

Details

Methods are defined for taking the polytope duals and for taking hyper-planar slices of a polytope. This paclet is under development.

Examples

Basic Examples

In[1]:=
vertices = RandomInteger[{-4, 4}, {50, 3}];
polytope = ConvexPolytope[vertices];
polytope // Polygon // Graphics3D
Out[3]=
In[4]:=
polytope = PolyhedronData["Dodecahedron", "VertexCoordinates"] // N // ConvexPolytope;
polytope // Polygon // Graphics3D
Out[5]=
In[6]:=
polytope = PolyhedronData["Dodecahedron", "VertexCoordinates"] // N // ConvexPolytope;
polytope = Join[polytope["Vertices"], Map[Mean, polytope["Facets"]]] // Map[Normalize] // ConvexPolytope;
polytope // Polygon // Graphics3D
Out[8]=
In[9]:=
polytope = PolyhedronData["Dodecahedron", "VertexCoordinates"] // N // ConvexPolytope;
polytope = Join[polytope["Vertices"], Map[Mean, polytope["Facets"]]] // Map[Normalize] // ConvexPolytope;
polytope = Join[polytope["Vertices"], Map[Mean, polytope["Facets"]]] // Map[Normalize] // ConvexPolytope;
polytope // Polygon // Graphics3D
Out[12]=
In[13]:=
polytope = PolyhedronData["Dodecahedron", "VertexCoordinates"] // N // ConvexPolytope;
polytope = Join[polytope["Vertices"], Map[Mean, polytope["Facets"]]] // Map[Normalize] // ConvexPolytope;
polytope = Join[polytope["Vertices"], Map[Mean, polytope["Facets"]]] // Map[Normalize] // ConvexPolytope;
polytope = polytope // ConvexPolytopeDual;
polytope // Polygon // Graphics3D
Out[17]=
In[18]:=
polytope = PolyhedronData["Dodecahedron", "VertexCoordinates"] // N // ConvexPolytope;
polytopeSlice = polytope["Slice", {1, 1, 1}, 0.0];

Graphics3D[{
  	{Opacity[0.5], polytope // Polygon},
  	{Red, polytopeSlice // Polygon},
  	{Lighter[Red], polytopeSlice // Tube[.05]},
  }, Boxed -> False]
Out[20]=

Scope

3D slices of a 4D hypercube (tesseract)

In[21]:=
Manipulate[
 skewMatrix4D = {{1, 0, 0, 0}, {0, 1, 0, 0}, {0, 0, 1, 0}, {3, 1, 1, 1}}; hypercubeVertices = Tuples[{-1, 1}, {4}] // N // Map[Normalize];
 hypercubeVertices = hypercubeVertices . RotationMatrix[\[Theta], {{1, 1, 1, 1}, {0, 0, 0, 1}}]\[Transpose];
 hypercubeVertices = hypercubeVertices . skewMatrix4D; hypercubePolytope = hypercubeVertices // N // ConvexPolytope; hypercubeSlicePolytope = hypercubePolytope["Slice", {0, 0, 0, 1}, sliceValue]; Graphics3D[{
   Specularity[1, 20],
   {Gray, hypercubePolytope // Tube[.03]},
   If[Positive[hypercubeSlicePolytope["Dimension"]],
    {
     {Red, hypercubeSlicePolytope // Polygon},
     {Black, hypercubeSlicePolytope // Tube[0.05]},
     {Black, hypercubeSlicePolytope // Sphere[0.1]}
     }
    ]
   }
  , PlotRange -> 3
  , Boxed -> False
  ]
 , {{sliceValue, 0.}, -1, 1}
 , {{\[Theta], 0.}, 0., Pi/2.}
 , {skewMatrix4D, None}
 , {hypercubeVertices, None}
 , {hypercubePolytope, None}
 , {hypercubeSlicePolytope, None}
 , TrackedSymbols :> {sliceValue, \[Theta]}
 ]
Out[21]=

600-cell (hexacosichoron)

In[22]:=
(* Evaluate this cell to get the example input *) CloudGet["https://www.wolframcloud.com/obj/d28cbb65-c49b-4a80-b29d-f2447db93601"]
Out[23]=
Out[24]=

120-cell (dodecacontachoron)

In[25]:=
c120Polytope = c600Polytope // ConvexPolytopeDual;
c120Polytope["FaceCounts"]
c120SlicePolytope = c120Polytope["Slice", {0, 0, 0, 1}, 0];
c120SlicePolytope // Polygon  // Graphics3D
Out[26]=
Out[28]=

Publisher

Dugan Hammock

Compatibility

Wolfram Language Version 13.3

Version History

  • 1.0.2 – 26 July 2023
  • 1.0.1 – 21 July 2023
  • 1.0.0 – 19 July 2023

License Information

MIT License

Paclet Source