# RegionUnion for 3D Regions

I make two regions and then find I can't combine them using RegionUnion. Here are the two regions.

r1 = Region@RegionDifference[
RegionDifference[Cylinder[{{0, 0, 0}, {20, 0, 0}}, 6],
Cuboid[{0, 5, -6}, {20, 6, 6}]],
Cuboid[{0, -6, -6}, {20, -5, 6}]
];
r2 = Region[Cylinder[{{20, 0, 0}, {28.5, 0, 0}}, 1/2]];
{r1, r2} Now I check their dimensions and plot them using Show.

    Show[r1, r2, Axes -> True, AxesLabel -> {"x", "y", "z"},
Boxed -> True] So far so good. Now I attempt to combine them using RegionUnion and then plot them over the same dimensions as I used in the Show

r3 = RegionUnion[r1, r2];
Region[r3, PlotRange -> {{0, 30}, {-5, 5}, {-5, 5}}, Axes -> True,
AxesLabel -> {"x", "y", "z"}, Boxed -> True] All I have is a cuboid at one end of my plot.

What's going wrong? Version 11.3

Edit

@N.J.Evans suggested I try a simpler region. It did't work for him in Version 11.2.

r0 = Region[Cuboid[{15, -5, -5}, {20, 5, 5}]] Show[r0, r2] r4 = RegionUnion[r0, r2];
Region[r4] So that worked in Version 11.3. Looks like we have different problems in different versions.

• Would it be acceptable to work with discretized regions in your application? If so, look into DiscretizeRegion. Feb 25, 2019 at 19:23
• @Hugh, that's better than what I got! I'm on 11.2 and I ran your code and got several errors when execution made it to r3, and then my CPU started working real hard and I had to kill the kernel. Maybe some kind of bug? I reduced it to the union of a cylinder and a cuboid and it still went crazy. Feb 25, 2019 at 19:30
• @MarcoB Thanks, but is there an easy way to join several regions after they have been discritised? Must I make one region and then discritise?
– Hugh
Feb 25, 2019 at 19:31
• @N.J.Evans Looking at a simpler union is a good idea. I will try.
– Hugh
Feb 25, 2019 at 19:37
• @Hugh I think Region function is meant for visualization purposes and you can drop it from inside RegionUnion and friends. Feb 26, 2019 at 7:51

Note that this is only an issue with the display -- the region itself is still correct. We can see this by sampling a bunch of random points:

Graphics3D[{PointSize[Tiny],
Point[RandomPoint[r3, 100000, {{0, 30}, {-5, 5}, {-5, 5}}]]}, Boxed -> False] As a workaround, you can discretize then perform boolean operations:

r1 = Fold[RegionDifference, BoundaryDiscretizeRegion /@ {Cylinder[{{0, 0, 0}, {20, 0, 0}}, 6],
Cuboid[{0, 5, -6}, {20, 6, 6}], Cuboid[{0, -6, -6}, {20, -5, 6}]}];

r2 = BoundaryDiscretizeRegion[Cylinder[{{20, 0, 0}, {28.5, 0, 0}}, 1/2]];

r3 = RegionUnion[r1, r2] • Yes this works well. Thank you. Clearly a plotting problem and working with BoundaryDiscretizeRegion gives a workaround.
– Hugh
Feb 26, 2019 at 9:28