################################################################################ ## Python script for Epitrochoid/Hypotrochoid Spirograph Coding ## Special cases: R=r {limacon} and d=r {epicycloid} ## -- ## Developed and coded (2024) ## by Angelea Arnett ## Revised (2025) ## by Robert Streubel ## -- ################################################################################ import numpy as np import pylab as pp #R is the radius of your inner ring# R = 11 #r is the radius of your outer ring# r = 1.6 #d is the distance from the center of the outer ring to your drawing point# d = 7.3 #Here we have our starting and ending angle of theta# start = 0 end = 100*np.pi """ This is the coding for the parametric equations. This also allows for the plotting of the functions. """ def Epitrochoid(t,R,r,d): return (R+r)*np.cos(t)-d*np.cos((R+r)/r*t), (R+r)*np.sin(t)-d*np.sin((R+r)/r*t) def Hypotrochoid(t,R,r,d): return (R-r)*np.cos(t)+d*np.cos((R-r)/r*t), (R-r)*np.sin(t)-d*np.sin((R-r)/r*t) t = np.arange(start,end,0.001) pp.figure() pp.xlim(-(R+r+d)*1.25,(R+r+d)*1.25) pp.ylim(-(R+r+d)*1.25,(R+r+d)*1.25) pp.title("Epitrochoid Spirograph") for i in range(5)[::-1]: pp.plot(*Epitrochoid(t,R,r,d*i/2),label=d*i/2) pp.legend() pp.figure() pp.xlim(-(R+r+d),(R+r+d)) pp.ylim(-(R+r+d),(R+r+d)) pp.title("Hypotrochoid Spirograph") pp.plot(*Hypotrochoid(t,R,r,d)) pp.figure() pp.xlim(-(R+r+d)*1.25,(R+r+d)*1.25) pp.ylim(-(R+r+d)*1.25,(R+r+d)*1.25) pp.plot(*Epitrochoid(t,R,r,d),label='Epitrochoid') pp.plot(*Hypotrochoid(t,R,r,d),label='Hypotrochoid') pp.legend() pp.show()