2
$\begingroup$

Edited at bottom - I think the problem is my unwise expectation to overlay Plot___ over Graphics objects and magically have them scale.

I have an entry-level manipulate that shows how a cycloid is traced by a point on the surface of a rolling wheel. I'm sure I can improve on this (suggestions welcome), but the thing that has me stumped is how to overlay/include an incremental parametric plot of the cycloid itself.

Rolling wheel

Manipulate[
 Graphics[{White, Rectangle[{0, -0.1}, {16, 3}], Blue, 
           Circle[{x, 1}, 1], Red, 
           Disk[{x - Sin[x - 1], 1 - Cos[x - 1]}, 0.1], Black, 
           Line[{{x, 1}, {x - Sin[x - 1], 1 - Cos[x - 1]}}  ],
          }], {x, 1, 14}]

That works the way I want it.

Try as I might, documentation (mis)reading notwithstanding I can't get this cycloid plot (Manipulates by itself without trouble (the arbitrary 22 for upper range is replaced by variable x when I try to embed in the Manipulate.

ParametricPlot[{t - Sin[t - 1], 1 - Cos[t - 1]}, {t, 1, 22}, 
 PlotRange -> {{0, 24}, {0, 2}}]

if I put the ParametricPlot (with x in place of 22) after the closing ] of the Line I get Graphics is not a Graphics primitive or directive.

If I do this (i.e. make the "expr" of Manipulate a List, with element 1= Graphics[... element 2= ParametricPlot... I get a bunch of errors pointing at a variable called FE`x$$261 which shows up in place of the x near the <<

I am missing something here - anything appreciated even RTFM URLs.

Manipulate[
 {Graphics[{White, Rectangle[{0, -0.1}, {16, 3}], Blue, 
    Circle[{x, 1}, 1], Red, 
    Disk[{x - Sin[x - 1], 1 - Cos[x - 1]}, 0.1], Black, 
    Line[{{x, 1}, {x - Sin[x - 1], 1 - Cos[x - 1]}}               ],
    }], 
    ParametricPlot[{t - Sin[t - 1], 1 - Cos[t - 1]}, {t, 1, x},    <<<HERE
    PlotRange -> {{0, 24}, {0, 2}}]}, {x, 1, 14}]

EDIT: I replaced the convenient Disk etc. with actual parametric plots and now have some progress. Won't bore the experts with my incremental learnings - will update this post when I have made as much progress as I can. Ultimately I want to have the cycloid tracing onto the plot as the manipulate-slider progresses

$\endgroup$
  • $\begingroup$ As a quick fix to get rid of the errors: Use a value > 1 as the smallest value in your Manipulate, e.g. {x, 1.00001, 14} instead of {x, 1, 14}. $\endgroup$ – Karsten 7. Feb 4 '15 at 5:38
  • $\begingroup$ possible spoiler: Making mathematical animations with Mathematica $\endgroup$ – Karsten 7. Feb 4 '15 at 7:42
  • 1
    $\begingroup$ Hint on how to "overlay Plot___ over Graphics objects and magically have them scale": Show. $\endgroup$ – Karsten 7. Feb 4 '15 at 7:48
  • $\begingroup$ Karsten7 - Show is exactly what I needed. As to duplicate question, the S/O searches I did - not already knowing the answer - didn't find anything that helped. Of course, if i do a search now including the word "show", I'd find all the answers I've seen since the help given on this question. $\endgroup$ – Paul_A Feb 5 '15 at 12:20
3
$\begingroup$

I did something like this using Animate once. Here is a Manipulate version.

enter image description here

Manipulate[
 r = 1;
 Show[{
   ListPlot[Table[{x - Sin[x], 1 - Cos[x]}, {x, 0, t, .1}], 
      Joined -> True, AspectRatio -> Automatic, 
    PlotRange -> {{-3, 20}, {-2 r, 3 r}}, ImageSize -> 500],
   Graphics[{Blue, PointSize[Large], Point[{t - Sin[t], 1 - Cos[t]}]}],
   Graphics[{Red, Circle[{t, 1}, r]}]
   }
  ],
 {{t, 0, "time?"}, 0, 20, .1}
 ]
| improve this answer | |
$\endgroup$

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