So, one thing you can do here is note that the equation for a cylinder extending along the z-axis is $x^2+y^2=0$, or $x^2+y^2leq0$ for a solid cylinder. That is, it’s the equation for a circle that ignores one of the axes! The other two just choose different axes to ignore. As such
RegionPlot3D({x^2 + y^2 <= 1, y^2 + z^2 <= 1, z^2 + x^2 <= 1}, {x, -2, 2}, {y, -2, 2}, {z, -2, 2})
gets you the three cylinders:
You can change the colors and styling with the options of RegionPlot3D
:
RegionPlot3D({x^2 + y^2 <= 1, y^2 + z^2 <= 1, z^2 + x^2 <= 1}, {x, -2, 2}, {y, -2, 2}, {z, -2, 2},
PlotStyle -> {Directive(Magenta, Opacity(0.5)), Directive(Cyan, Opacity(0.5)), Directive(Yellow, Opacity(0.5))},
Mesh -> False)
Importantly, you can get cross sections by And
-ing (&&
) these conditions with the condition for being below a plane. Consider the plane specified by $x+y-2z=0$; we have
RegionPlot3D({x^2 + y^2 <= 1 && x + y + z/2 >= 0,
y^2 + z^2 <= 1 && x + y + z/2 >= 0,
z^2 + x^2 <= 1 && x + y + z/2 >= 0}, {x, -2, 2}, {y, -2, 2}, {z, -2, 2},
PlotStyle -> {Directive(Magenta, Opacity(0.5)), Directive(Cyan, Opacity(0.5)), Directive(Yellow, Opacity(0.5))},
Mesh -> False,
PlotPoints -> 100)
Note that we also had to set PlotPoints
to a higher number to get something that looks nice! You could make it even higher to make it look better.
(Now, you might be wondering: how do I automate this to produce a grid? And is the Cylinder
graphics primitive better? Maybe. I’ll try to update this answer when I have a chance later!)