# Is it possible to unit discrete region and use RegionDifference to subtract it?

I am testing my idea to find the difference between two regions, while one region has discrete sub-regions. I find that RegionUnion and RegionDifference have problems dealing with such problems. I post my script here for a quick check

 d1 = Disk[{0.5, 0.5}, 0.4];
d2 = Disk[{1.5, 1.5}, 0.4];
d3 = Disk[{1.5, 0.5}, 0.4];
d4 = Disk[{0.5, 1.5}, 0.4];
u1 = Region[RegionUnion[d1, d2, d3, d4], Axes -> True,
AxesOrigin -> {0, 0}]
RegionDimension[u1]
Area[u1]
u2 = Region[Rectangle[{0, 0}, {2, 2}], Axes -> True,
AxesOrigin -> {0, 0}]
RegionDimension[u2]
D1 = Region[RegionDifference[u2, u1], Axes -> True,
AxesOrigin -> {0, 0}]


I hope to get the region without those four disks in the rectangle. but the code just give the region of the left corner part.

• Region isn't a valid command. Just do, eg: u1 = RegionUnion[d1, d2, d3, d4], and the RegionPlot[u1]. Also, probably don't want to be using capital D as a variable name. – aardvark2012 Oct 7 '17 at 7:32
• Thanks. That means Region command is not a command to define a region, and we don't need to define something as region before apply region related commands. Is it right? – Dai Weijing Oct 8 '17 at 23:36
• Ah, apparently Region is a command. Introduced in v.11, presumably. Sorry, my bad. But yeah, not a command to define a region. – aardvark2012 Oct 8 '17 at 23:40

Only use Region when you want to view the region. The following does what you want:

u1 = RegionUnion[d1, d2, d3, d4];
u2 = Rectangle[{0,0}, {2,2}];
Region @ RegionDifference[u2, u1]
`