5
$\begingroup$

I often met with the case where I want to show the past trajectory of a object. A way of demonstrating this is to plot the trajectory using ParametricPlot, and then change the time interval of the plot.

For example, consider a object moving on 2D trajectory given by two interpolating functions, I could use the following code to showcase the movement of the object:

f = Array[Interpolation[RandomReal[{0, 1}, 100]][t] &, 2]
Manipulate[ParametricPlot[f, {t,1,tt},PlotRange->{{0,1},{0,1}}],{tt,2,100}]

When dragging the slider, ParametricPlot will replot the figure again and again. And to reduce lagging, Mathematica will reduce the PlotPoints option when control is active, causing the lines to distort. Note that in real applications the function might be much more complicated, so it's not feasible to just increase the plot points like PlotPoints->10000.

However, in this particular case, we could plot the figure from t=1 to 100 and just display the part between 1 and tt, saving the replot process. So my question is, is this possible or are there any other way to improve the performance of such animations? Thanks!

$\endgroup$

1 Answer 1

0
$\begingroup$

Increased PlotPoints avoid distortions:

Manipulate[
 ParametricPlot[t {Cos[t], Sin[t]}, {t, 0, tt},
  PlotPoints -> 100,
  PlotRange -> {{-100, 100}, {-100, 100}}], {tt, 1, 100}]
$\endgroup$

Your Answer

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

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