1
$\begingroup$

I am plotting the convex hull of some curves by extracting the curves from a contour plot and constructing the convex hull around their discretized version . It's not terribly accurate for calculations but it works well for a quick visualization.

Here's a simple example.

curve = ContourPlot3D[{((x - 0.5)^2 + (y - 0.5)^2 + (z - 
     0.5)^2) ((x + 0.5)^2 + (y + 0.5)^2 + (z + 0.5)^2) == 2,
     x^2 + y^2 + z^2 == 1}, {x, -1.1, 1.1}, {y, -1.1, 1.1},
     {z, -1.1, 1.1}, ContourStyle -> None, Mesh -> 0, 
     BoundaryStyle -> {1 -> None, 2 -> None, {1, 2} -> {Blue, Thickness[0.015]}},
     PlotPoints -> 30];

hull = ConvexHullMesh@MeshCoordinates@Quiet@DiscretizeGraphics@First@Normal@curve;

Show[curve,hull]

The result is a convex hull with a mesh of all the polygons:

Convex hull

Can I turn this into an object that I can display a normal, coordinate-based mesh on? Something like this

Mesh example

that would work for any convex hull.

I want to do this because the convex hull mesh is ugly, but if I remove it it becomes difficult to see where a convex hull bends, where it's round etc.

$\endgroup$
3
  • $\begingroup$ what about hull["Graphics3D"]? $\endgroup$
    – RunnyKine
    Apr 29, 2016 at 1:23
  • $\begingroup$ @RunnyKine Hm. That doesn't seem to accept any options related to the mesh, unfortunately. $\endgroup$
    – T.J.
    Apr 29, 2016 at 1:58
  • $\begingroup$ @RunnyKine I have added an example. $\endgroup$
    – T.J.
    Apr 29, 2016 at 2:14

1 Answer 1

2
$\begingroup$

You've created a MeshRegion, so you can plot it with RegionPlot3D,

Of course, since your cylinder is rotated with respect to the cartesian coordinates, you'll need to find the right combination of coordinates to give the mesh you want.

Here are some examples,

RegionPlot3D[hull, Mesh -> 10, MeshFunctions -> #, Axes -> True, 
   ImageSize -> 400] & /@ 
      {{#1 &, #2 &}, 
       {1/4 (2 - Sqrt[2]) #1 + 1/4 (2 + Sqrt[2]) #2 - #3/2 &,
        -(#1/2) + #2/2 + #3/Sqrt[2] &},
       {1/4 (2 + Sqrt[2]) #1 + 1/4 (2 - Sqrt[2]) #2 &,
        1/4 (2 - Sqrt[2]) #1 + 1/4 (2 + Sqrt[2]) #2 &, 
        -(#1/2) + #2/2 &}, 
       {1/4 (2 + Sqrt[2]) #1 + 1/4 (2 - Sqrt[2]) #2 + #3/2 &,
        -(#1/2) + #2/2 + #3/Sqrt[2] &}}

enter image description here

This set of coordinates comes close to matching the original mesh,

RegionPlot3D[hull, Mesh -> 15, 
 MeshFunctions -> {(1/Sqrt[2.] (#1 - #2) &), (1/Sqrt[
      2.] (-#1 + #3) &), 1/Sqrt[3] (#1 + #2 + #3) &},
 Axes -> True, ImageSize -> 400]

Mathematica graphics

$\endgroup$

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.