Draw circles and compute <sum of circle areas>-<area of overlaps of the circles>
I am not sure are you interested in the union of the disks or the union sans the intersections. The code below can be used for both cases.
Implicit regions
r = 0.18;
regs = ImplicitRegion[
Sqrt[(x - #[[1]])^2 + (y - #[[2]])^2] <= r, {x, y}] & /@ pts;
Circles drawing
Show[mesh,
Graphics[{Cyan, Circle[#, r] & /@ pts, Black, Point[pts], Red,
Point[vertices]}], Axes -> True]
Union
c = Ceiling[Max[pts] + r, 0.5];
AbsoluteTiming[
dregs = DiscretizeRegion[RegionUnion[regs], {{-2, 2}, {-2, 2}},
ImageSize -> Medium]
]
RegionMeasure[dregs]
(* 1.99653 *)
Union \ Intersection
ires = DeleteCases[
Flatten[Table[
RegionIntersection[regs[[i]], regs[[j]]], {i, 1,
Length[regs]}, {j, i + 1, Length[regs]}]], _EmptyRegion];
AbsoluteTiming[
dires = DiscretizeRegion[RegionUnion[ires], {{-c, c}, {-c, c}},
ImageSize -> Medium, Frame -> True, PlotRange -> {{-c, c}, {-c, c}}]
]
RegionMeasure[dregs] - RegionMeasure[dires]
(* 1.56288 *)
radius = .18;
disks = Disk[#, radius] & /@ pts;
25 Area[disks[[1]]]
2.54469
Area[RegionUnion[disks]]
2.03381
Show[mesh, Graphics[{Black, Point[pts], Red, Point[vertices],
FaceForm[Opacity[.5,LightGreen]],EdgeForm[{Thick,Darker@Green}], disks}]]
I think it is much better to use RegionMeasure
on the undiscretized regions. For instance:
disks = Disk[#, .18]& /@ pts;
ru = RegionMeasure @ RegionUnion[disks]
RegionMeasure @ DiscretizeRegion @ RegionUnion[disks]
2.03381
1.99723
The region measure of the discretized version is almost 2% off. Similarly:
ires = DeleteCases[
Flatten @ Table[
RegionIntersection[disks[[i]], disks[[j]]],
{i, 1, 25},
{j, i + 1, 25}
],
_EmptyRegion
];
int = RegionMeasure @ RegionUnion @ ires
RegionMeasure @ DiscretizeRegion @ RegionUnion @ ires
0.44757
0.439748
So a more accurate answer would be:
ru - int
1.58624
Finally, it is possible to get this result directly by using BooleanCountingFunction
:
RegionMeasure @ BooleanRegion[
BooleanCountingFunction[{1}, 25],
disks
]
1.58624
although this version is slower than Antons.