Cycloid, Epicycloid, Hypocycloid

One of my favorite extra credit assignments from Calculus 3 was graphing an Epicycloid. I extended the problem, and derived the parametric equation for a hypocycloid as well just for fun. My Professor actually ended up putting the parametric equation for a hypocycloid as a bonus on one of our tests! Here is the code.

In [1]:
%pylab inline
import matplotlib as mpl
from mpl_toolkits.mplot3d import Axes3D
import numpy as np
import matplotlib.pyplot as plt
Populating the interactive namespace from numpy and matplotlib
In [2]:
#Cycloid
theta = linspace(0, 4*np.pi)
x = theta - sin(theta)
y = 1 - cos(theta)
plt.plot(x,y)
plt.show()
In [3]:
#Epicycloid
theta = linspace(0, 100*np.pi, 1000)
r1 = 12
r2 = 7
x = ((r1 + r2) * cos(theta)) + (r2 * cos(theta * (1 + r1/r2) - np.pi))
y = ((r1 + r2) * sin(theta)) + (r2 * sin(theta * (1 + r1/r2) - np.pi))
plt.plot(x,y)
plt.show()
In [4]:
#Hypocycloid
theta = linspace(0, 100*np.pi, 1000)
r1 = 12
r2 = 7
x = ((r1 - r2) * cos(theta)) + (r2 * cos(theta * ((r1 - r2)/r2) - np.pi))
y = ((r1 - r2) * sin(theta)) - (r2 * sin(theta * ((r1 - r2)/r2) - np.pi))
plt.plot(x,y)
plt.show()