1
$\begingroup$
m1 = 3.5;
m2 = 1.7;
m3 = 0.3;
x1[t_] = Sin[3 t];
y1[t_] = 2 t^2 - 1;
x2[t_] = 4 Log[3 t + 2];
y2[t_] = Sin[2 t];
x3[t_] = Tan[5/(t + 1)];
y3[t_] = Exp[-2 t];
T = 2;
M = m1 + m2 + m3;
xC[t_] = (m1 x1[t] + m2 x2[t] + m3 x3[t])/M;
yC[t_] = (m1 y1[t] + m2 y2[t] + m3 y3[t])/M;
Animate[ParametricPlot[{xC[t], yC[t]}, {t, 0, 2}], {?? ??}]

How to make the "animate" change the value of t?

$\endgroup$
  • $\begingroup$ What exactly to you mean by change the value of t? t is already fixed by ParametricPlot, so it's not a variable in the animated expression any more. Do you want to vary the range of t? What exactly should be animated? $\endgroup$ – Martin Ender Mar 1 '15 at 11:01
  • $\begingroup$ I need to show the process of drawing this graph with the change t. $\endgroup$ – Mike Mar 1 '15 at 11:06
  • $\begingroup$ If you want to change the range of t you could do something like ..., {t, 0, u}], {u, 0, 2}]. You might have to fix PlotRange in ParametricPlot then though so that the frame remains the same throughout the animation. $\endgroup$ – Martin Ender Mar 1 '15 at 11:09
  • $\begingroup$ Thank you, man!how can I put you plus? $\endgroup$ – Mike Mar 1 '15 at 11:15
1
$\begingroup$

You can animate the function being drawn by varying the range of t, not t itself (since t is already fixed). However, you'll need to fix PlotRange (and probably PlotPoints) for animation to look nice:

Animate[
  ParametricPlot[
    {xC[t], yC[t]}, 
    {t, 0, u}, 
    PlotRange -> {{-1.5, 3.5}, {-1, 4.5}}, 
    PlotPoints -> 60
  ], 
  {u, 0.01, 2}
]

Note that your function has a discontinuity at $ t = (10 - 3\pi)/3\pi $ (there are others, but this is the one within $[0,2]$). Mathematica plots the function by sampling it and joining up the samples, so you'll get a line where the discontinuity should be. This can be fixed with Exclusions. Just add another option to ParametricPlot:

  ...,
  Exclusions -> (10 - 3 \[Pi])/(3 \[Pi])
]
$\endgroup$
  • $\begingroup$ And another question. Because of x3 [t_] = Tan [5 / (t + 1)];, graph on top does not look good, is this normal? $\endgroup$ – Mike Mar 1 '15 at 11:21
  • $\begingroup$ I do not have enough reputation to vote up $\endgroup$ – Mike Mar 1 '15 at 11:25
  • $\begingroup$ @Mike I addressed the discontinuity. $\endgroup$ – Martin Ender Mar 1 '15 at 11:31
  • $\begingroup$ You're a great help, thank you very much $\endgroup$ – Mike Mar 1 '15 at 11:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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