# usage: gnuplot < spiro3.gp ; xv spiro3.png # ###spiro3.gp spirograph 3-wheel trochoids with gnuplot! ###22aug07 from http://linuxgazette.net/133/luana.html # set terminal png #size 600,600 x000000 xffffff x404040 xff0000 set output "spiro3.png" # set size ratio -1 set nokey set noxtics set noytics set noborder set parametric #--------------- trochoid equations ----------- x(t)=(R-r)*cos(t) + p*cos((R-r)*t/r) y(t)=(R-r)*sin(t) - p*sin((R-r)*t/r) # #----- Greatest common divisor: gcd(x,y) = (x%y==0 ? y : gcd(y,x%y)) # R=100; r=-49; p = -66; res = 10 ##must be integers # rr = abs(r) nturns = rr / gcd(R,rr) samp = 1 + res * nturns set samples samp # plot [t=0:nturns*2*pi] x(t),y(t) ### R=radius of fixed circle; r= of small circle; p=angle; res=resolutn ### circle: p=0; ellipse: R=2r and p≠r, its axes being (r+p) and |r-p|; ### R=2r=2p gives rise to a line of length 2a; ### hypocycloids are obtained by choosing p=r; ### negative p and/or r results in some extraordinary specimens.