Skip to main content

graphics3d - Convex hull of a 3D object?


I am trying to find a convex hull command for a Graphics3D object. Does it exist in Mathematica?


egg = Graphics3D[Cuboid /@ Position[DiskMatrix[{12, 10, 8}], 1]]

Mathematica graphics


The ConvexHull command of the "ComputationalGeometry`" package does not work on 3D objects:



Needs["ComputationalGeometry`"]
ConvexHull[egg]

Mathematica graphics



Answer



Since ConvexHull doesn't support 3D points (and you incorrectly tried to compute the ConvexHull of the Graphics object) your code didn't work.


Here is one way to do what I think you want (I left out of the step of the Cuboids but if you want that basically just offset your convex hull).


Needs["TetGenLink`"]

pos = Position[DiskMatrix[{12, 10, 8}], 1];

Graphics3D[Point@pos]

Mathematica graphics


{pts, surface} = TetGenConvexHull[pos];
Graphics3D[GraphicsComplex[pts, Polygon[surface]]]

Mathematica graphics


If you do want to compute the ConvexHull of your Graphics3D object you can extract the points from the InputForm. This is fragile and will only work for this simple case.


pos = InputForm[egg][[1, 1, All, 1]]

Comments