# Cross-section parts of a Cube and show results graphically

I am trying to visualize a 3D section of a chopped up 1x1x1 Cube. I don't want to use the Cube[] function to draw this. (unless you think you can still accomplish it that way). Ok, so say you have a simple XY plane, laying flat on the table (lengths 1x1) Now I draw 2 straight lines across it with equations: Y=X+1/2 and Y=X-1/2 and shade the region in between. (it'll take up 75% of the 1x1 region of course with the top left and bottom right squares being half shaded now, and the other 2 squares fully shaded). Ok simple enough so far.

Now let's draw up the Z-axis above this (Hold the ruler perpendicular to the table up to a height of 1). Now raise/stretch that same shaded region above to the top, which will still take up the 75% of the now-8 0.5x0.5 cubes). with 2/8 unshaded. Ok now imagine the ZX plane (facing you on the table) and draw up the same 2 equations, now: Z=X+1/2 and Z=X-1/2 so you now have the same regions covering the ZX plane and they now travel to the back of the Cube - and the main point, now intersect the previous region (coming up from XY plane).

I like to visualize both shaded intersection. In other words, how can I draw up both regions, shade them, then put them into 3D for both planes and be able to rotate that final 3D image in any direction I like to visualize that highlighted 3D-intersection.

P.S. Too much in language, for those who like pure equations, in a nutshell this is all I need:

Y=X(+/-)1/2 and Z=X(+/-)1/2 < == 3D Plot and visualize intersection region in between the 2 pairs of lines on each plane.

Assume/hope your solution can take in any Function cutting the cube: Say Y=f(X) and Z=g(X)?

Co-incidentally, assume this is also possible to solve algebraically?

@Steve237

RegionPlot3D[
And @@ {x - 1/2 <= y <= x + 1/2, x - 1/2 <= z <= x + 1/2,
0 <= x <= 1, 0 <= y <= 1, 0 <= z <= 1}, {x, 0, 1}, {y, 0, 1}, {z,
0, 1}, PlotPoints -> 80, PlotStyle -> Opacity[0.2], Mesh -> None,
BoundaryStyle -> Blue, AxesLabel -> {"x", "y", "z"},
LabelStyle -> Directive[Red, Bold], TicksStyle -> Orange]


• Thx @cvgmt! Looks great, I plotted it. Last thing: Can I put the X,Y,Z labels on the axis so when I rotate it around, I know which plane I'm looking at? Nov 19, 2020 at 3:26
• @Steve237 Yes, we can add AxesLabel -> {"x", "y", "z"}. I add some codes to the answer. Nov 19, 2020 at 3:35
• Thx, works great! Nov 19, 2020 at 3:43

Here is an approach that seems to stem from the equations you mentioned at the end. I am not sure that I have interpreted them correctly, but even if I have not, perhaps it will get you started:

DiscretizeRegion[
ImplicitRegion[
{x - 1/2 <= y <= x + 1/2, x - 1/2 <= z <= x + 1/2}, {x, y, z}
],
{{0, 1}, {0, 1}, {0, 1}},
Axes -> True, Boxed -> True,
Method -> "Semialgebraic"
]


• Yes this is great Marco, Thx! Is there a way for Mathematica to compute the percentage of shaded area? Nov 18, 2020 at 3:03
• @Steve237 reg = ImplicitRegion[{x - 1/2 <= y <= x + 1/2, x - 1/2 <= z <= x + 1/2 , 0 <= x <= 1, 0 <= y <= 1, 0 <= z <= 1}, {x, y, z}] // Volume // N Nov 18, 2020 at 3:14
• Thx cvgmt! Is there a way to make the original shape transparent/see-thru? Nov 18, 2020 at 4:58