1
$\begingroup$

If I cover a square of side $L$ with $n$ unit disks at random (the disks may overlap the boundary), is there a standard way to evaluate the total covered area $A$?

I am looking to observe the density $f_{A}(x)$.

I am thinking to use implicit region, with the distance to at least one disk centre lesson than 1, but how to you evaluate the area?

enter image description here

$\endgroup$
8
  • 1
    $\begingroup$ r1 = Region[Disk[]] RegionMeasure[r1] gives $\pi$. $\endgroup$
    – Syed
    Nov 19 '21 at 17:14
  • $\begingroup$ Ok so just apply this to Region[...] of a set of random disks? $\endgroup$
    – apkg
    Nov 19 '21 at 17:20
  • 1
    $\begingroup$ Not Mathematica tip, but check out section "A Generalized Niche Model" in this article. $\endgroup$
    – Chris K
    Nov 19 '21 at 19:03
  • 1
    $\begingroup$ Highly relevant because it should describe the most performant(?) algorithm known: Edelsbrunner: The Union of Balls and Its Dual Shape. $\endgroup$ Nov 20 '21 at 11:32
  • 1
    $\begingroup$ With that accuracy you want the answer? Would the share of black pixels on the picture suffice? $\endgroup$
    – Andrew
    Nov 20 '21 at 20:49
1
$\begingroup$

This code will produce a histogram of the random area. It is a bit slow, perhaps someone knows how to speed it up.

area[n_] := Module[{c, r1}, c = RandomReal[{-2, 2}, {n, 2} ];
  RegionMeasure[
   RegionIntersection[{Rectangle[{-3, -3}, {3, 3}], 
     RegionUnion[Disk[#, 1] & /@ c]}]]]
Histogram[Table[36 - area[10], {i, 1, 100}], {1}];

enter image description here

c = RandomReal[{-2, 2}, {10, 2} ];
RegionPlot[RegionIntersection[{Rectangle[{-3, -3}, {3, 3}], 
     RegionUnion[Disk[#, 1] & /@ c]}]]

enter image description here

$\endgroup$
4
  • $\begingroup$ You don't take into account the condition" a square of side $ L $". Your RegionPlot differs from the plot in the question. To this end it is enough to take the intersection with a given square in your Module. $\endgroup$
    – user64494
    Nov 19 '21 at 20:46
  • $\begingroup$ Updated, had altered the code for second figure $\endgroup$
    – apkg
    Nov 19 '21 at 22:11
  • $\begingroup$ Also to demonstrate the "edge" cases, you can have circles closer to the edges and partly outside the rectangular area. $\endgroup$
    – Syed
    Nov 20 '21 at 6:47
  • $\begingroup$ It should be RandomReal[{-3, 3}, {n, 2} ] in your code to satisfy the request in the question. $\endgroup$
    – user64494
    Nov 20 '21 at 12:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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