Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

I am fairly new to Mathematica and I cannot figure out how to plot an epicycloid. I have plotted some neat looking things in my attempts, but can't make one. I am not looking to make an animation, just the result of an epicycloid.

Would I use a PolarPlot or ParametricPlot? How do I get a static picture of an epicycloid?

share|improve this question
    
so what did you try then? where did you fail? –  Pinguin Dirk Sep 16 '13 at 14:53
5  
Welcome to Mathematica.SE! Have a look at demonstrations.wolfram.com/search.html?query=epicycloid –  Yves Klett Sep 16 '13 at 14:56
    
Mostly a lot of fiddling with the epicycloid equations in a PolarPlot (and some ParametricPlots). –  btalbot Sep 16 '13 at 14:56
3  
@PinguinDirk is asking you to post the code you have tried thus far, so we can see where there might be a problem. –  bobthechemist Sep 16 '13 at 15:20

4 Answers 4

up vote 21 down vote accepted

I recreated the animation on Wikipedia for those who like such things (I do).

enter image description here

Here is the Manipulate version:

R = 3; r = 1;

fx[θ_, a_: 1] := (R + r) Cos[θ] - a r Cos[(R + r) θ/r];
fy[θ_, a_: 1] := (R + r) Sin[θ] - a r Sin[(R + r) θ/r];

gridlines = Table[{x, GrayLevel[0.9]}, {x, -6, 6, 0.5}];

plot[max_] := ParametricPlot[
  {fx[θ], fy[θ]}, {θ, 0, max},
  PlotStyle -> {Red, Thick},
  Epilog -> {
    Thick,
    Blue, Circle[{0, 0}, R],
    Black, Circle[{fx[max, 0], fy[max, 0]}, r],
    Red, PointSize[Large], Point[{fx[max], fy[max]}],
    Black, Line[{{fx[max, 0], fy[max, 0]}, {fx[max], fy[max]}}]
    },
  GridLines -> {gridlines, gridlines},
  PlotRange -> {-6, 6}
  ]
Manipulate[plot[max], {max, 0.01, 2 Pi}]
share|improve this answer

Epicycloids (and other roulette curves) are fun to play with using Manipulate. Here is one of many possible implementations.

Manipulate[
  ParametricPlot[{
    (1 + r)  Cos[theta] + a Cos[(1 + r) theta], 
    (1 + r) Sin[theta] + a Sin[(1 + r) theta]}, 
    {theta, 0, 2 Pi}],
  {{r, 1}, 1, 20, 1, Appearance -> "Labeled"},
  {{a, 1}, -10, 10, .2, Appearance -> "Labeled"}]

epicycloid.png


Edit

Although the question only calls for epicycloids, it is very easy to make interactive panel that allows the user to play with hypocycloids as well. Because there is a simple relationship between epicycloids and hypocycloids, doing so adds very little code.

Manipulate[
  ParametricPlot[{
      type r Cos[theta] + a Cos[type r theta], 
      type r Sin[theta] + a Sin[type  r theta]},
    {theta, 0, 2 Pi},
    PlotStyle -> {Red, Thick},
    ImageSize -> {400, 400}],
  {{type, 1}, {1 -> "epicycloid", -1 -> "hypocycloid"}},
  {{r, 1}, 1, 20, 1, Appearance -> "Labeled"},
  {{a, 1}, -10, 10, .1, Appearance -> "Labeled"}]

roulettes.png

share|improve this answer

It is easiest to use ParametricPlot and RotationTransform.

ParametricPlot[
  RotationTransform[a][{1, 0}] + RotationTransform[4 a][{1/4, 0}],
  {a, 0, 2 Pi}, Evaluated -> True]

enter image description here

Evaluated -> True is not strictly necessary; it's there just to construct the equation once instead of for every point in the graph separately (... which is slow).

EDIT: Improved per comment from Mr.Wizard.

share|improve this answer
2  
+1 -- however, I recommend using the Evaluated -> True option rather than Evaluate to properly localize a. Please see: (7832), (5220), (7561) –  Mr.Wizard Sep 16 '13 at 17:34

Looking up epicycloid we get the parametric equations describing it and then ParametricPlot does the rest of our work.

ParametricPlot[
     {3 3.1 Cos[θ] - 3 Cos[3.1 θ], 3 3.1 Sin[θ] - 3 Sin[3.1 θ]}, 
     {θ, 0, 20 π},
     ColorFunction -> "AtlanticColors"]

Plot

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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