1
$\begingroup$

A code can trace the kinetic point.But when you slide the bar too fast,you cannot get smooth curve like fllowing.

a = 2; p = {{0, 0}};
Manipulate[
 Graphics[{{EdgeForm[{Thin, Black}], FaceForm[Pink], 
    Disk[{a \[Theta], a}, a]}, {Blue, PointSize[Medium], 
    BezierCurve[
     AppendTo[p, 
      point = {a (\[Theta] - Sin[\[Theta]]), a (1 - Cos[\[Theta]])}]],
     Point[point]}}, Axes -> True, Frame -> False, 
  PlotRange -> {{-2, 6 \[Pi] a}, {-2, 3 a}}], {\[Theta], 0, 6 \[Pi]}]

enter image description here

The reason is the Manipulate produce too less value of Theta that the BezierCurve isn't precise:

a = 2; p = {{0, 0}};
Manipulate[
 Graphics[{{EdgeForm[{Thin, Black}], FaceForm[Pink], 
    Disk[{a \[Theta], a}, a]}, {Blue, PointSize[Medium], 
    Point[AppendTo[p, 
      point = {a (\[Theta] - Sin[\[Theta]]), a (1 - Cos[\[Theta]])}]],
     Point[point]}}, Axes -> True, Frame -> False, 
  PlotRange -> {{-2, 6 \[Pi] a}, {-2, 3 a}}], {\[Theta], 0, 6 \[Pi], 
  1/1000}]

enter image description here

So how to make the Manipulate produce more value of Theta during the slider being slided.

$\endgroup$
  • $\begingroup$ A Manipulate with only one slider is pretty much equivalent to an Animate, and with frames that are slow to render I would then simply use ListAnimate to pre-render everything. I only use Manipulate when two ore more parameters need to be varied simultaneously. $\endgroup$ – Jens Mar 5 '16 at 17:26
3
$\begingroup$

There are few things that need to be changed in your code.

First you need to wrap the BezierCurve with Dynamic and TrackedSymbols to prevent continues updating of AppendTo.

Second you need to sort p so that when slider move back the BezierCurve is appropriate.

a = 2; p = {{0, 0}}; Manipulate[
 Graphics[{{EdgeForm[{Thin, Black}], FaceForm[Pink], 
    Disk[{a \[Theta], a}, a]}, {Blue, PointSize[Medium], 
    Dynamic[BezierCurve[
      Sort@AppendTo[p, 
        point = {a (\[Theta] - Sin[\[Theta]]), 
          a (1 - Cos[\[Theta]])}]], TrackedSymbols :> {\[Theta]}], 
    Point[point]}}, Axes -> True, Frame -> False, 
  PlotRange -> {{-2, 6 \[Pi] a}, {-2, 3 a}}], {\[Theta], 0, 6 \[Pi]}]

Apart from that, if you are looking just for graphics then why not simply use ParametricPlot ?

a = 2;
Manipulate[
 Show[{Graphics[{{EdgeForm[{Thin, Black}], FaceForm[Pink], 
      Disk[{a t, a}, a]}, {Blue, PointSize[0.02], 
      Point[{a t - a Sin[t], a - a Cos[t]}]}}, Axes -> True, 
    PlotRange -> {{-2, 6 \[Pi] a}, {-2, 3 a}}], 
   ParametricPlot[{a \[Theta] - a Sin[\[Theta]], 
     a - a Cos[\[Theta]]}, {\[Theta], -.01, t}, 
    PlotStyle -> Blue]}], {t, 0, 15 a}]

In this case I would suggest you use the following method:

a = 2; 
p = {{0, 0}}; 
Manipulate[
     Graphics[{{EdgeForm[{Thin, Black}], FaceForm[Pink], 
        Disk[{a \[Theta], a}, a]}, {Blue, PointSize[Medium], 
        BezierCurve[
         p = Sort@
           Table[{a (t - Sin[t]), a (1 - Cos[t])}, {t, 0, \[Theta], .1}]],
         Point[Last@p]}}, Axes -> True, Frame -> False, 
      PlotRange -> {{-2, 6 \[Pi] a}, {-2, 3 a}}], {\[Theta], 0, 
      6 \[Pi], .1}]
$\endgroup$
  • $\begingroup$ Better than my code.But when I slide it too fast for the first time,the effect is bad still. $\endgroup$ – yode Mar 5 '16 at 16:59
  • $\begingroup$ @yode, what are you trying to get? is it the plot only or the plot and the list p? $\endgroup$ – Algohi Mar 5 '16 at 17:00
  • $\begingroup$ The qeustion have posted that method with ParametricPlot before this edit.But in some case ,the equation(or parametric equation) isn't easy to confirm.So I try to avoid use the ParametricPlot.All the same,thanks for your advice. $\endgroup$ – yode Mar 5 '16 at 17:06
  • 2
    $\begingroup$ +1 The second solution is fantastic! Not only fast but I very much like the removal of the curve when the disk rolls back. $\endgroup$ – Jack LaVigne Mar 5 '16 at 17:09

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.