4
$\begingroup$

I want to ask is it possible to make the overlapped part to be transparent in Graphics3D.

Graphics3D[{Brown, {Cuboid[{0, 0, 0}, {0.8, 0.1, 2}], Opacity[0], 
   White, Cuboid[{0.1, -0.001, 1.35}, {0.7, 0.101, 1.85}]}}]
$\endgroup$
1
  • $\begingroup$ Graphics3D[{Brown, {Cuboid[{0, 0, 0}, {0.8, 0.1, 2}], White, {Cuboid[{0.1, -0.001, 1.35}, {0.7, 0.101, 1.85}], Opacity[0]}}}, Lighting -> {{"Ambient", White}}] $\endgroup$ Dec 7, 2014 at 19:46

2 Answers 2

5
$\begingroup$

You can also use RegionPlot3D:

cuboid1 = {{0, 0, 0}, {0.8, 0.1, 2}};
cuboid2 = {{0.1`, -0.001`, 1.35`}, {0.7`, 0.101`, 1.85`}};
{cuboid1b, cuboid2b} = Insert[#, {x, y, z}, 2] & /@ {cuboid1, cuboid2};
{region, hole} = (And @@ Less @@@ Transpose@#) & /@ {cuboid1b, cuboid2b};

RegionPlot3D[region && Not[hole],{x, 0, 2}, {y, 0, 2}, {z, 0, 2},
 PlotPoints -> 200, MaxRecursion -> 6, PlotStyle -> Brown, Mesh -> None, 
 Lighting -> "Neutral", Boxed -> False, Axes -> False]

enter image description here

$\endgroup$
4
$\begingroup$

One way to make transparent regions is to use RegionFunctions. For example, here are your two cubes and then the "symmetric difference" between them. This essentially removes the smaller one from the larger, and leaves a transparent window.

r1 = Cuboid[{0, 0, 0}, {0.8, 0.1, 2}];
r2 = Cuboid[{0.1, -0.001, 1.35}, {0.7, 0.101, 1.85}];
d = RegionSymmetricDifference[r1, r2]
Show[BoundaryDiscretizeRegion[d]]

enter image description here

$\endgroup$
3
  • $\begingroup$ It seems Mathematica 9 doesn't have funtions RegionSymmetricDifference[] and BoundaryDiscretizeRegion[]. $\endgroup$ Dec 7, 2014 at 20:06
  • 1
    $\begingroup$ That's true -- I just learned about these functions from here: wolfram.com/broadcast/video.php?c=376&v=1230 $\endgroup$
    – bill s
    Dec 7, 2014 at 20:08
  • $\begingroup$ If don't use the two functions, having other ways can do this? $\endgroup$ Dec 7, 2014 at 20:54

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.