0
$\begingroup$

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?

$\endgroup$
1
  • $\begingroup$ Linked topic should address all your concerns, let me know if you disagree with closing. $\endgroup$
    – Kuba
    Apr 13, 2018 at 6:20

1 Answer 1

1
$\begingroup$

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

$\endgroup$
2
  • $\begingroup$ 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? $\endgroup$ Apr 13, 2018 at 0:59
  • $\begingroup$ @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. $\endgroup$ Apr 13, 2018 at 2:06

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