# Only show part of a cube below an intersecting plane

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]

=================

Closely related: 37025
– Kuba
Dec 11 ’14 at 7:22

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}]
– Kuba
Dec 11 ’14 at 7:28

=================

3

=================

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]

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]

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      Interesting observation. – Kuba Dec 11 '14 at 8:52