How can I constrain the locator to stay within the region defined by RegionPlot
?
When the Locator
remains within the region, NDSolve
generates a periodic solution. (The boundary of the region represents a homoclinic orbit for the DE. When the Locator
is outside the boundary of the region, NDSolve
generates an unbounded orbit. Actually, the boundary of the region is the solution to the DE with initial condition $x(0) = -6,\; y(0) = 0$.)
Additionally a strange behavior occurs whenever the left mouse button is pressed: the right end of the region is truncated. Why?
Manipulate[
region = RegionPlot[y^2 < x^2*(1 + x/6), {x, -6, 0}, {y, -2.5, 2.5}];
sol = NDSolve[{x'[t] == y[t], y'[t] == x[t] + x[t]^2/4,
x[0] == p[[1]], y[0] == p[[2]]}, {x, y}, {t, 0, T}];
psol = ParametricPlot[Evaluate[{x[t], y[t]} /. sol], {t, 0, T},
PlotRange -> {{-6, 0}, {-3, 3}}, PlotStyle -> Red ];
Show[{region, psol}], {{p, {-2, 0}}, Locator}, {{T, 5}, 0, 12, 0.1}]
I suspect that Dynamic
needs to be introduced here, but I don't know how to implement it successfully.
PerformanceGoal -> "Quality"
toRegionPlot
to override the default settingsPerformanceGoal -> ControlActive["Speed", "Quality"]
for plots insideManipulate
. $\endgroup$