I would like to define a region consisting of a polygon with eight holes in it. This is essentially a stamped piece of metal with eight holes.

a01 = Disk[{-0.5, 1},0.1];
a02 = Disk[{-1.5, 1},0.1];
a03 = Disk[{-2.5, 1},0.1];
a04 = Disk[{-3.5, 1},0.1];
a05 = Disk[{-4.5, 1},0.1];
a06 = Disk[{-5.5, 1},0.1];
a07 = Disk[{-6.5, 1},0.1];
a08 = Disk[{-7.5, 1},0.1];

aRegion = RegionUnion[ a01,
                       a08 ];

bRegion = Polygon[ {{-12.5,6}, {12.5, 6}, {6.5, 0}, {-6.5, 0}} ];

\[CapitalOmega] = Region @ RegionDifference[aRegion, bRegion]

The aRegion is a series of eight holes.

aRegion as a union of eight holes.

The bRegion is a simple polygon. bRegion as a simple polygon.

I am trying to create a polygon with eight holes. The result of the RegionDifference is shown below.

RegionDifference result

Note that if I swap the parameters in the call to RegionDifference, I get the bRegion polygon without holes.

What would be the correct way to define a region that is essentially the bRegion polygon minus the aRegion holes?


2 Answers 2


You mixed up the ordering of bRegion and aRegion. Moreover, Region is only suitable for a quick preview; it usually does not discretize very accurately. Try DiscretizeRegion with variable MaxCellMeasure instead.

\[CapitalOmega] = DiscretizeRegion[RegionDifference[bRegion, aRegion], 
  MaxCellMeasure -> 0.001]

enter image description here

You may also try to specify a suitable MeshRefinementFunction in order to localize the refinement of the mesh around the holes.


As Henrik has pointed out, the holes are there when the parameterization of RegionDifference is correct. Sometimes having Infix notation in mind will help to avoid mistakes.

Another advice is to start using contructor functions with parameters defined only once (e.g. using scoping constructs like With) right from the start. So mind the advice: Don't repeat yourself (DRY). This helps to easily "play around" with what you have done. Using a larger radius, for example, would have quickly shown that the holes are there even in the coarse output produced by Region but are simply to small (e.g. setting radius to 0.3 would have sufficed).

Next to discretizing there is RegionPlot, which offers more control with regard to the outcome:

    r = 0.1, (* radius of holes *)
    xmin = -12.5,
    xmax = 12.5,
    ymin = 0,
    ymax = 6,
    holesX = Range[-0.5, -7.5, -1],
    holesY = 1,
    minus = RegionDifference
  aRegion = RegionUnion @ Map[Disk[{#, holesY}, r] &, holesX];
  bRegion = Polygon @ { {xmin, ymax}, {xmax, ymax}, {6.5, ymin}, {-6.5, ymin} };
  Ω = bRegion ~ minus ~ aRegion; (* infix makes this more readable *)
  RegionPlot[ Evaluate @ RegionMember[ Ω, {x, y} ] 
    , {x, xmin, xmax}
    , {y, ymin, ymax}
    , AspectRatio -> (ymax - ymin)/(xmax - xmin)
    , PlotPoints -> 200



Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.