Using Convex Hulls in 3D

A few Demonstrations using ConvexHull3D no longer work. It was an undocumented feature of previous versions, and isn’t in Version 10. So, how to do the same thing in version 10?

initpts = Union[N[Flatten[{Table[{Sin[x],Cos[x],0}, {x,0,2 Pi,2 Pi/50}], 
    Table[{Sin[x],0,Cos[x]} + {2,0,0}, {x,0, 2 Pi, 2 Pi/50}]}, 1]]]; 
meshobject = ConvexHullMesh[initpts];
pts = MeshCoordinates[meshobject];
polys = MeshCells[meshobject, 2];
Graphics3D[{EdgeForm[], GraphicsComplex[pts, polys]}, Boxed -> False, 
        SphericalRegion -> True, ImageSize -> {400, 400}]

The variables pts and polys are the vital items for GraphicsComplex.

5 Likes

It is in the documentation on ConvexHullMesh. Applying to your case:

initpts = Union[N[Flatten[{Table[{Sin[x], Cos[x], 0}, {x, 0, 2 Pi, 2 Pi/50}], 
             Table[{Sin[x], 0, Cos[x]} + {2, 0, 0}, {x, 0, 2 Pi, 2 Pi/50}]}, 1]]];
ConvexHullMesh[initpts]

1 Like

Sam, yes, you can get that picture – but you can’t put Graphics3D options on it. You can’t use SphericalRegion → True, for example. I wrote up this note for people that want to extract the polygons from ConvexHullMesh.

1 Like

Ahh, I misunderstood. Well thanks for that code - I see now that it is very useful.

You can get a GraphicsComplex with

ConvexHullMesh[initpts]["GraphicsComplex"]

or get graphics with

 ConvexHullMesh[initpts]["Graphics3D"]

(You can get many such things. See ConvexHullMesh[initpts]["Properties"].)

2 Likes