Message Boards Message Boards

[✓] Plot the circles within a Manipulate?

GROUPS:

Consider the following code:

hypocycloid[tend] := 
 Module[{a = 4, b = 1, x, y, p}, 
  x[t_, p_] := b (a/b - 1) Cos[t] + b p Cos[(a/b - 1) t];
  y[t_, p_] := b (a/b - 1) Sin[t] - b p Sin[(a/b - 1) t]; 
  ParametricPlot[{x[t, 1], y[t, 1]}, {t, 0, tend}, 
   PlotStyle -> {Red, Thick}, Ticks -> None, ImageSize -> 225, 
   Epilog -> {Thick, Blue, Circle[{0, 0}, a], Black, 
     Circle[{x[tend, 0], y[tend, 0]}, b], Red, PointSize[Large], 
     Point[{x[tend, 1], y[tend, 1]}], Black, 
     Line[{{x[tend, 0], y[tend, 0]}, {x[tend, 1], y[tend, 1]}}]}, 
   PlotRange -> (1 + 1/20) {-a, a}]];

Manipulate[Quiet@hypocycloid[tend], {tend, .0001, 2*Pi}]
POSTED BY: Lisan Lisov
Answer
3 months ago

It does work if you define your functions properly:

hypocycloid[tend_] := 
Module[{a = 4, b = 1, x, y, p}, 
x[t_, p_] := b (a/b - 1) Cos[t] + b p Cos[(a/b - 1) t]; 
y[t_, p_] := b (a/b - 1) Sin[t] - b p Sin[(a/b - 1) t]; 
ParametricPlot[{x[t, 1], y[t, 1]}, {t, 0, tend}, 
PlotStyle -> {Red, Thick}, Ticks -> None, ImageSize -> 225, 
Epilog -> {Thick, Blue, Circle[{0, 0}, a], Black, 
Circle[{x[tend, 0], y[tend, 0]}, b], Red, PointSize[Large], 
Point[{x[tend, 1], y[tend, 1]}], Black, 
Line[{{x[tend, 0], y[tend, 0]}, {x[tend, 1], y[tend, 1]}}]}, 
PlotRange -> (1 + 1/20) {-a, a}]];

Then

Manipulate[Quiet@hypocycloid[tend], {tend, .0001, 2*Pi}]

does work.

enter image description here

Cheers,

Marco

POSTED BY: Marco Thiel
Answer
3 months ago

Thank you, Marco. I did not understand how you make it to run continuously. Please explain. Thank you again.

POSTED BY: Lisan Lisov
Answer
3 months ago

Group Abstract Group Abstract