0

I'm trying to make a manipulate that shows a parametric plot of a cycloid with manipulators that affect the shape of the curve. My problem seems to be my scoping of the variable R in the code below. This is what I've tried so far:

x[th_]:=R(th - Sin[th])
y[th_]:=R(1 - Cos[th])

DynamicModule[{R,q=({x[#],-y[#]})&}, Manipulate[
    ParametricPlot[q[ph],{ph,0,th}],
{{th,0,"\[Theta]"},0,2 Pi, Appearance->"Labeled"},
{{R,1,"radius"},0.01,10, Appearance->"Labeled"}]]

This results in the dynamic value of R not being scoped into q. What am I missing here?

terrygarcia
  • 236
  • 1
  • 5
  • Linked topic should address all your concerns, let me know if you disagree with closing. – Kuba Apr 13 '18 at 06:20

1 Answers1

1

How about something like this:

x[R_, th_] := R (th - Sin[th]);
y[R_, th_] := R (1 - Cos[th]);
Manipulate[
 ParametricPlot[{x[R, ph], -y[R, ph]}, {ph, 0, th}], 
   {{th, 0.1,"\[Theta]"}, 0, 2 Pi, Appearance -> "Labeled"}, 
   {{R, 1, "radius"}, 0.01, 10, Appearance -> "Labeled"}]

enter image description here

bill s
  • 68,936
  • 4
  • 101
  • 191
  • This works, but I'd prefer to have R be a constant (in math speak) rather than a parameter. Any way that I can use Dynamic to do this? – terrygarcia Apr 13 '18 at 00:59
  • @terry, let's just say it's poor Mathematica practice to construct functions that do not take all needed parameters as arguments. So: R = 2; x[th_] := R (th - Sin[th]) and x[R_, th_] := R (th - Sin[th]) are OK, but plain x[th_] := R (th - Sin[th]) and leaving R undefined is not. – J. M.'s missing motivation Apr 13 '18 at 02:06