Skip to main content

plotting - Count the number of regions made by Lissajous curve


How many disconnected regions does Lissajous curve divide the plane into?



For example: Let


g = ParametricPlot[{Sin[2 t], Sin[t]}, {t, 0, 2 π}]

enter image description here


The number of disconnected regions made by curve g is 3.



Answer



I don't like to think too much :P


Manipulate[
{#, Composition[
# - 1 &,

Length,
Union,
Flatten,
MorphologicalComponents,
Binarize,
Rasterize
]@#} &@
ParametricPlot[{Sin[ n t], Sin[m t]}, {t, 0, 2 Pi}, Axes -> False,
PlotStyle -> Thick]
, {n, 2, 10, 1}, {m, 1, 9, 1}]


enter image description here


Comments