I want to include the some region plots in a Manipulate structure, however the rendering is almost prohibitively slow. The code is
ClearAll[regions, rplot]
r:regions[n_Integer, o_Integer] := r = Apply[And,
Subsets[Table[(#1 - Cos[t])^2 + (#2 - Sin[t])^2 <= 1, {t, 2 Pi/n,
2 Pi, 2 Pi/n}], {o}], {1}] &
r:rplot[n_Integer, o_Integer] := r = Show[{RegionPlot[
Evaluate[regions[n, o][x, y]], {x, -2, 2}, {y, -2, 2},
PlotRange -> {{-2, 2}, {-2, 2}}, PlotRangePadding -> .1,
Frame -> False, PlotPoints -> 100],
Graphics[Table[Circle[{Cos[t], Sin[t]}, 1], {t, 2 Pi/n, 2 Pi, 2 Pi/n}]]}]
Which produces graphics like
GraphicsGrid[{{rplot[3, 2], rplot[5, 3]}, {rplot[7, 2], rplot[4, 1]}}]

The above takes about 40 seconds to calculate and render on my computer.
Can anyone suggest a way to get similar quality graphics more quickly?
Note 1: I’ve memoized the graphics object so that doesn’t need to recalculate it each time in my demonstration – but it’s too slow even the first time.
Note 2: I’m happy with rasterized images, so maybe a flood fill type solution would be an option…
Note 3: I need something like Manipulate[ to be usable.
rplot[n, o], {n, 2, 10, 1, Appearance -> "Labeled"}, {{o, 1},
Range[1, (n + 1)/2], ControlType -> RadioButtonBar}]
I previously posted this as an addition to my other answer. It’s inspired by Simon’s analytic approach, with some modifications to speed things up
First of all, I’m using that for given value of
nando, the intersection region between thei-th andi+o-1-th circle is the same as the intersection region between the first ando-th circle except for a rotation over an angle2 Pi (i-1)/n, so it suffices to calculate the region once and useRotateto rotate the region.Also, instead of using a ParametricPlot to plot the intersection region, I’m using a
Polygonso I only need to calculate some points on the boundary which saves time.The result for
GraphicsGrid[{{rplot2[3, 2], rplot2[5, 2]}, {rplot2[7, 3], rplot2[4, 1]}}]looks likeAnd the timings I get are
compared to those for Simon’s solution