3
$\begingroup$

How can I animate a point on a polar curve? I have used Animate and Show together before in order to get the curve and the moving point together on the same plot, but combining the polar plot and the point doesn't seem to be working because point only works with Cartesian coordinates.

Here is the code I used before to animate a point on a parametric curve. For higher values of a and theta, you can see the point moving along the curve better (I was required to animate all three parameters).

Animate[
 Show[
  ParametricPlot[{a Cos[θ] t, a Sin[θ] t - 4.9 t^2}, {t, 0, 15}, AxesLabel -> {"x", "y"},
   PlotRange -> {{0, 50}, {0, 30}}],
  Graphics[{Red, PointSize[.05], Point[{a Cos[θ] t, a Sin[θ] t - 4.9 t^2}]}]
 ],
 {t, 0, 5, Appearance -> "Labeled"},
 {a, 1, 20, Appearance -> "Labeled"},
 {θ, 0, Pi/2, Appearance -> "Labeled"},
 AnimationRunning -> False
]

Here is the code I tried to use to animate a point on a polar curve, but the point does not even show up.

Animate[
 Show[
  PolarPlot[2 Sin[4*θ], {θ, 0, 2 Pi}],
  Graphics[Red, PointSize[Large], Point[{2 Sin[4*θ] Cos[θ], 2 Sin[4*θ] Sin[θ]}]]
 ],
 {θ, 0, 2 Pi}, 
 AnimationRunning -> False
]
$\endgroup$
  • 1
    $\begingroup$ Please include the code you have tried so far, the one you have used before, and we'll go from there. $\endgroup$ – MarcoB Nov 16 '15 at 17:33
3
$\begingroup$

It is not necessary to resort to Show. Your animation can easily be accomplished with Epilog.

Animate[
  PolarPlot[2 Sin[4 θ], {θ, 0, 2 Pi}, 
    Epilog -> 
      {Red, PointSize[Large], Point[{2 Sin[4 θ] Cos[θ], 2 Sin[4*θ] Sin[θ]}]}],
  {θ, 0, 2 Pi},
  AnimationRunning -> False] 
$\endgroup$
3
$\begingroup$

Conceptually you are there already; you only had a small syntax error in your code, i.e. a missing set of braces around the items in the Graphics expression:

Animate[
 Show[
  PolarPlot[2 Sin[4*t], {t, 0, 2 Pi}],
  Graphics[{Red, PointSize[0.02], Point[{2 Cos[θ] Sin[4 θ], 2 Sin[θ] Sin[4 θ]}]}]
  ],
 {θ, 0, 2 Pi},
 AnimationRunning -> False
]

The problem is more visible if you temporarily comment out the PolarPlot expression from your code; the resulting Graphics will then complain of an incorrect syntax issue, which is what led me to discover the problem.

As a small improvement, I would suggest that you write your transformed point as:

Point[Sin[4 θ] {Cos[θ], Sin[θ]}]

This way you can avoid having to rewrite your polar function twice.

$\endgroup$
2
$\begingroup$
Animate[
 ParametricPlot[f[a, s, u], {u, 0, 15}, 
  PlotRange -> {{0, 50}, {0, 30}}, 
  Epilog -> {Red, PointSize[0.05], Point[f[a, s, t]]}], {a, 1, 
  20}, {s, 0, Pi/2}, {t, 0, 5}, 
 Initialization :> (f[a_, s_, t_] := 
    a t { Cos[s] , Sin[s]} - {0, 4.9 t^2})]

enter image description here

I have not done all the niceties but suggest this suffices to operationalize.

$\endgroup$
2
$\begingroup$
Animate[PolarPlot[2 Sin[4 θ], {θ, 0, 2 Pi}, Axes -> False, 
            MeshFunctions -> {#3 &}, Mesh -> {{{θ, Directive[Red, PointSize[Large]]}}}], 
       {θ, 0, 2 Pi}, AnimationRunning -> False]

enter image description here

$\endgroup$
0
$\begingroup$
Animate[
 Show[
  PolarPlot[Sin[3 t], {t, 0, π}],
  Graphics[{Red, PointSize[0.02], 
    Point[Sin[3 θ] {Cos[θ], Sin[θ]}]}]],
 {θ, 0, π}]
$\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.