3
$\begingroup$

Let's say I have the following animation:

Animate[ParametricPlot[{Cos[a t], Sin[a t]}, {t, 0, 1}], {a, 0, 
  2Pi}, AnimationRate -> 0.1]

Is there a way to somehow zoom into the moving point of the animated plot at a preselected xy-coordinate or time; such as being able to zoom into the animated moving point after 3 seconds or when the moving point reaches {x,y}={-1,0}?

Any help would be appreciated.

$\endgroup$

2 Answers 2

5
$\begingroup$

You can make PlotRange a function of any variables you need it to be a function of. I believe how to do it is most clearly explained with code:

f[t_] := With[{a = 2 Pi/20}, {Cos[a t], Sin[a t]}]
plotRangeF[t_, x_] := Which[
  t >= 0 && t < 5, {{0, 1}, {0, 1}},
  t >= 5 && t < 10, {{-1, 0}, {0, 1}},
  t >= 10 && t < 15, {{-1, 0}, {-1, 0}},
  t >= 15 && t <= 20, {{0, 1}, {-1, 0}}
  ]
frame[t_] := Graphics[{
   Point[f[t]]
   }, PlotRange -> plotRangeF[t, f[t]]
  ]
ListAnimate[Table[frame[t], {t, 0, 20, 0.1}]]

I think this may solve your problem. Do note that ParametricPlot also has the PlotRange option.

$\endgroup$
6
  • $\begingroup$ this does not show anything like the original question was asking $\endgroup$
    – am70
    Jul 2 at 20:20
  • $\begingroup$ @am70 It solved the problem and was accepted. $\endgroup$
    – C. E.
    Jul 2 at 22:34
  • $\begingroup$ first of all, the code snippet is lacking several semicolons; second and most important, if you run the original code from the OP, you see the animation of a circle that is being drawn; if you run the code from C.E. , it shows a point moving in an abstract space, no circle, no axes, no reference: so it is not even clear if this solution is "zooming" in some sense.. $\endgroup$
    – am70
    Jul 11 at 11:31
  • $\begingroup$ another weird fact in this solution is that plotRangeF[t_, x_] does not really use x $\endgroup$
    – am70
    Jul 11 at 13:41
  • $\begingroup$ Let me also add another info: Which will stop at the first matching clause; so it is easier to write Which[ t<5, a, t<10, b...] than Which[ t>0 && t<5, a,t≥5 && t<10, b...] $\endgroup$
    – am70
    Jul 11 at 14:20
0
$\begingroup$

here is the animation of the OP, but with an initial zoomout, and then tracking of the drawing point

f[x_] := {Cos[2 \[Pi] x ], Sin[2 \[Pi] x ]};
squareF[t_, r_] := {  { f[t][[1]] - r, f[t][[1]] + r} ,
   { f[t][[2]] - r, f[t][[2]] + r} };
plotRangeF[t_] := Which[
   t < 1/6, squareF[t,  5 t + 1/6],
   True, squareF[t,  1]];
frame[t_] := 
  ParametricPlot [f[t x], {x, 0, 1}, PlotRange -> plotRangeF[t]];
animation = ParallelTable[frame[t], {t, 0, 1, 0.01}];
ListAnimate[animation, DefaultDuration -> 10]

squareF defines a square around the moving point, of side 2 r ; changing the Which part in PlotRangeF , you may zoom in and out at will

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.