0
$\begingroup$

I am trying to represent the motion of a particle along a given trajectory. So I defined the following functions

x[t_] := Cos[t]

y[t_] := Sin[t]

T[t_] := {x[t], y[t]}

Trajectory = ParametricPlot[T[t], {t, 0, 2*Pi}, ImageSize -> Large,AspectRatio -> 1];

P[t_] := Point[T[t]]

V[t_] = Arrow[{T[t], T[t] + {x'[t], y'[t]}}];

and so I give the command

Animate[Show[Trajectory, Graphics[V[t], P[t]]], {t, 0, 2*Pi}]

but unfortunately the final result is really stranger and moreover I do not see the point P in the motion but only the velocity vectors and the trajectory that strangely changes its size. So could someone help me, please?

$\endgroup$
9
  • $\begingroup$ If you indend by 4spaces your code is shown (I edited your question accordingly) $\endgroup$ Nov 22, 2021 at 15:31
  • 1
    $\begingroup$ Fix Show by adding PlotRange and wrapping V[t] and P[t] into a list: Show[Trajectory, Graphics[{V[t], P[t]}], PlotRange -> {{-2, 2}, {-2, 2}}]. $\endgroup$
    – Domen
    Nov 22, 2021 at 15:36
  • $\begingroup$ @UlrichNeumann Okay, thanks for the edit. $\endgroup$ Nov 22, 2021 at 15:36
  • $\begingroup$ @Domen Okay, it works for a circumference but strangely it does not work for a parabol, e.g. try to put x[t_]:=t, y[t_]:=t^2. $\endgroup$ Nov 22, 2021 at 15:43
  • $\begingroup$ @Domen E.g. see this x[t_] := t y[t_] := t^2 T[t_] := {x[t], y[t]} Trajectory = ParametricPlot[T[t], {t, 0, 5}, ImageSize -> Large, AspectRatio -> 1]; P[t_] := Point[T[t]] V[t_] = Arrow[{T[t], T[t] + {x'[t], y'[t]}}]; Animate[Show[Trajectory, Graphics[{V[t], P[t]}], PlotRange -> {{0, 25}, {0, 25}}], {t, 0, 5}] $\endgroup$ Nov 22, 2021 at 15:46

1 Answer 1

1
$\begingroup$

Try

Trajectory =ParametricPlot[T[t], {t, 0, 2*Pi}, ImageSize -> Large,AspectRatio -> 1, PlotRange -> 1.5 {{-1, 1}, {-1, 1}}];

P[t_] := Point[T[t]]

V[t_] := Arrow[{T[t], T[t] + {x'[t], y'[t]}}];

Animate[Show[{Trajectory, Graphics[{V[t], P[t]}, PlotRange -> 1.5 {{-1, 1}, {-1, 1}}]}, ImageSize -> 300], {t, 0, 2*Pi}]

enter image description here

The same algorithm works for any possible motion: anyway the value of t in Trajectory and in Animate must be only one and moreover the PlotRange in Animate must be adjusted conveniently

$\endgroup$

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.