Skip to main content
edited tags; edited tags
Link
cvgmt
  • 84k
  • 6
  • 97
  • 179
Became Hot Network Question
Tweeted twitter.com/StackMma/status/1517292195421769728
edited tags
Link
cvgmt
  • 84k
  • 6
  • 97
  • 179
Source Link
Taozi
  • 529
  • 2
  • 10

Divide a geometric region by (many) lines

Given a shape (e.g., a rectangle, a circle, etc.), how to divide it by $n$ randomly chosen lines. It is trivial to plot those lines (see figure below), using code like

Graphics[Table[{Hue[RandomReal[]], Opacity[0.8], 
   InfiniteLine[RandomReal[{-1, 1}, {2, 2}]]}, {49}], 
 PlotRange -> {{-1, 1}, {-1, 1}}, Frame -> True]

But how to extract the (many) regions in the figure? There are some posts doing similar things to an image (https://community.wolfram.com/groups/-/m/t/388948), but I am not sure how to do that to geometric shapes. Thanks!

random lines