2
$\begingroup$

I plot a cube and a plane. I just want to show the part below the plane.

The code:

p2 = Animate[
Show[{Graphics3D[Cuboid[{2, -2, -1}, {-2, 2, 3}], Boxed -> False], 
ContourPlot3D[{z - t y - t x == 0}, {x, -3, 3}, {y, -3, 
  3}, {z, -7, 7}, 
 MeshFunctions -> {Function[{x, y, z, f}, 
    x^2 + y^2 - r^2 - z + t y + t x]}, Mesh -> False, 
 ContourStyle -> 
  Directive[Yellow, Opacity[0.5], Specularity[White, 30]], 
 Boxed -> False, AxesOrigin -> {0, 0, 0}, BoxRatios -> Automatic, 
 ImageSize -> 400]}], {{t, -0}, -3, 3}, AnimationRunning -> False]

enter image description here

$\endgroup$
2
  • $\begingroup$ Closely related: 37025 $\endgroup$
    – Kuba
    Dec 11, 2014 at 7:22
  • $\begingroup$ I'd say a duplicate. That's why I'm leaving this here: Manipulate[ Graphics3D[Cuboid[{2, -2, -1}, {-2, 2, 3}], Boxed -> False, ClipPlanes -> {-{-t, -t, 1, 0}}], {{t, -0}, -3, 3}] $\endgroup$
    – Kuba
    Dec 11, 2014 at 7:28

3 Answers 3

3
$\begingroup$

Using ClipPlanes and ClipPlanesStyle

Animate[Graphics3D[Cuboid[{2, -2, -1}, {-2, 2, 3}], 
  ClipPlanes -> -{-t, -t, 1, 0}, Boxed -> False, 
  ClipPlanesStyle -> 
   Directive[Yellow, Opacity[0.5], Specularity[White, 30]]
  ], {{t, -0}, -3, 3}, AnimationRunning -> False]

enter image description here

$\endgroup$
2
$\begingroup$
p2 = Animate[Show[{
    RegionPlot3D[
     And[-2 < x < 2, -2 < y < 2, -1 < z < 3, z - t y - t x < 0], 
        {x, -4, 4}, {y, -4, 4}, {z, -4, 4}
        ],
    ContourPlot3D[{z - t y - t x == 0}, {x, -3, 3}, {y, -3, 
      3}, {z, -7, 7}, 
     MeshFunctions -> {Function[{x, y, z, f}, 
        x^2 + y^2 - r^2 - z + t y + t x]}, Mesh -> False, 
     ContourStyle -> 
      Directive[Yellow, Opacity[0.5], Specularity[White, 30]], 
     Boxed -> False, AxesOrigin -> {0, 0, 0}, BoxRatios -> Automatic, 
     ImageSize -> 400]}], {{t, -0}, -3, 3}, AnimationRunning -> False]

enter image description here

$\endgroup$
2
$\begingroup$

This is just an extended comment.

The corners that you used to define the Cuboid do not define a valid region.

While Cuboid[{2, -2, -1}, {-2, 2, 3}] and Cuboid[{-2, -2, -1}, {2, 2, 3}] fill the same space, Mathematica only considers the second Cuboid to be a valid region.

RegionQ /@ {
  Cuboid[{2, -2, -1}, {-2, 2, 3}],
  Cuboid[{-2, -2, -1}, {2, 2, 3}]}

{False, True}

RegionMember[
 Cuboid[{-2, -2, -1}, {2, 2, 3}],
 {x, y, z}]

-2 <= x <= 2 && -2 <= y <= 2 && -1 <= z <= 3

$\endgroup$
1
  • $\begingroup$ Interesting observation. $\endgroup$
    – Kuba
    Dec 11, 2014 at 8:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.