Plotting an epicycloid

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?

-
so what did you try then? where did you fail? – Pinguin Dirk Sep 16 '13 at 14:53
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
@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

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

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}]

-
I don't know how many hours I've spent (wasted) on playing with roulettes, but it sure was fun. :) – J. M. May 3 '15 at 6:54

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]


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.

-
+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

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"}]


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"}]


-

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"]


-