Take a set of points in the plane and draw a circle of a given radius at each point. The resulting pattern of circles may look something like this:
Graphics[Circle[#, 9/10] & /@ Tuples[Range[7], 2], PlotRange -> {{1, 6}, {1, 6}}]
Notice all of the small regions that are formed by these intersecting circles. How can I get each of these regions as say, a list of Region
objects?
EDIT: I've adapted the code by kglr to compute what I want. Here is the resulting code:
tuples = Tuples[Range[4], 2];
disks = Disk[#, 0.9] & /@ tuples;
intersecting[d_] :=
DeleteCases[Select[disks, ! RegionDisjoint[d, #] &], d]
funcs[a_, b_] :=
If[a == b, {BooleanCountingFunction[{a}, b]},
Thread[BooleanConvert[BooleanCountingFunction[{a}, b]] /.
Or -> List]]
regs[n_] :=
DeleteDuplicatesBy[
Flatten[
Function[x,
Select[
RegionIntersection[
x,
BooleanRegion[#, intersecting[x]]
] & /@ funcs[n, Length[intersecting[x]]]
, Quiet[RegionDimension[#]] == 2 &
]
] /@ disks
],
RegionCentroid
]
The resulting regions look like this:
r = regs /@ Range[3];
colours = {Red, Green, Blue};
Show[Flatten[(Function[x, Region[x, BaseStyle -> FaceForm[colours[[#]]]]] /@ r[[#]]) & /@ Range[3]]];
Circle
aRegion
usingDisk
it's pretty easy to doRegionIntersection
over the pairs or triples orRegionDifference
over the quadruples. $\endgroup$