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 π}]


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

• And what have you tried? – Kuba May 12 '15 at 11:20
• Seems like a mathematics question. Isn't it just 2 plus the number of crossings, provided it's a closed curve with simple crossings? – Michael E2 May 12 '15 at 11:56
• Not sure how general this is: perhaps GraphicsMeshMeshInit[];1 + Length@ GraphicsMeshFindIntersections[ ParametricPlot[{Sin[# t], Sin[ (# - 1) t]}, {t, 0, 2 Pi }]] & /@ {2, 3, 4, 5}? – kglr May 12 '15 at 12:07
• @kguler Oh,guy,why the answer of Length@GraphicsMeshFindIntersections[ ParametricPlot[{Sin[2 t], Sin[(2 - 1) t]}, {t, 0, 2 Pi}]] is 2?But it should be 1 .Somthing wrong? – WateSoyan May 12 '15 at 12:15
• @WateSoyan, for a closed curve the starting point is also an intersection (it intersects with the ending point). – kglr May 12 '15 at 12:45

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}]


• A similar method was used to count the self-intersections of Lissajous curve. – WateSoyan May 12 '15 at 12:10
• @WateSoyan it depends on what do you mean by similar, but it doesn't seem so. – Kuba May 12 '15 at 12:18
• Your code is so applicable that I benefit a lot from it.:) – WateSoyan May 12 '15 at 12:45
• You might want to add imagesize, which is a function of n and m – Alexey Bobrick May 15 '15 at 14:52
GraphicsMeshMeshInit[];
eps = 1/100000000;
Manipulate[Labeled[plt = ParametricPlot[{Sin[n t], Sin[(n - 1) t]}, {t, eps, 2 Pi},
Axes -> False, PlotStyle -> Thick]; plt /. Line -> Polygon,
Grid[{{"n", "p"}, {n, 2 + Length@GraphicsMeshFindIntersections[plt]}},
ItemStyle -> Directive[16, "Panel"]], Top], {n, 2, 10, 1}]


• Your method is nice.Thank you.But could you explain why your code should return a true result? – WateSoyan May 12 '15 at 12:47
• @WateSoyan, rough/raw intuition: every time a simple curve intersects itself it creates a new region/polygon (try it with pen and paper). – kglr May 12 '15 at 12:56
• Yes,in this cases, it's true.But I think it's not always be true in other cases. – WateSoyan May 12 '15 at 13:05
• By any chance, @Wate, are you in any way familiar with Euler's $v-e+f=2$? – J. M.'s ennui May 12 '15 at 14:34
• However, @Wate, you only asked about Lissajous curves in the question; these curves will only exhibit double nodes, so kguler's counting strategy works here. If you want to ask about rosettes instead, ask a new question. – J. M.'s ennui May 13 '15 at 2:16