2
$\begingroup$

I'm trying to clip a cone both from top and bottom using IntervalSlider. I'm able to clip it from the bottom but not from the top.

Manipulate[
 Graphics3D[{FaceForm[Green, Pink], Cone[]}, 
  ClipPlanes -> {InfinitePlane[{{0, 0, z[[1]]}, {1, 0, z[[1]]}, {0, 1,
        z[[1]]}}], 
    InfinitePlane[{{0, 0, -z[[2]]}, {1, 0, -z[[2]]}, {0, 
       1, -z[[2]]}}]}], {z, -1, 1, ControlType -> IntervalSlider, 
 Method -> "Push", MinIntervalSize -> 0.1}]

Any help?

$\endgroup$
4
$\begingroup$

The problem is, how to specify that the plane should cut content below or above itself.

Answer

I couldn't find notes about that in documentation but it seems, and is reasonable, that the order of points in InfinitePlane's specification determines that. So if you reverse the order of points in the second plane you will get what you need.

Tip

Clipping is controlled by FE so you can use ClipPlanes -> Dynamic[...]. This will improve performance as the whole Graphics3D will not need to be recreated each time.

Final code

Manipulate[
     Graphics3D[{FaceForm[Green, Pink], Cone[]}
       , ClipPlanes -> Dynamic@{
           InfinitePlane[{{0, 0, z[[1]]}, {1, 0, z[[1]]}, {0, 1, z[[1]]}}], 
           InfinitePlane[
             Reverse@{{0, 0, z[[2]]}, {1, 0, z[[2]]}, {0, 1, z[[2]]}}
           ]
         }
     ]
  , {z, -1, 1
    , ControlType -> IntervalSlider
    , Method -> "Push"
    , MinIntervalSize -> 0.1
    }
]

enter image description here

|improve this answer|||||
$\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.