set style line 100 lw 0.05 lc rgb "#663300"
set pm3d depth lighting hidden3d ls 100
set xyplane 0
unset key
unset tics
unset border
unset colorbox
set samples 384
set isosamples 18
set xr [-2:2]
set yr [-2:2]
set zr [-2:2]
set view equal xyz
set view 72,218,2.2
set palette defined ( 0 "#ffcc66", 1 "#ffcc66")

R = 2.0
r = 0.5
al = 3.0
bt = -7.0
s = 0.1

set parametric
set ur [0:pi]
set vr [0:2*pi]
set xr [-2.5:2.5]
set yr [-2.5:2.5]
set zr [-2.5:2.5]

rr(u,t) = (R+r)/2 + (R-r)/2*cos(al*u + t)
fx(u,t) = rr(u,t)*cos(bt*u)
fy(u,t) = rr(u,t)*sin(bt*u)
fz(u,t) = (R-r)/2 * sin(al*u + t)
dr(u,t) = -al*(R-r)/2*sin(al*u + t)
dx(u,t) = -(dr(u,t)*cos(bt*u) - rr(u,t)*bt*sin(bt*u))
dy(u,t) =  (dr(u,t)*sin(bt*u) + rr(u,t)*bt*cos(bt*u))
q(u,t) = atan2(dx(u,t),dy(u,t))


N = 20
set term pngcairo size 360,360 background rgb "#114400"
do for [i = 0:N-1] {

  set out sprintf("helix%03d.png",i)
  t = i * 2.0*pi/N/7
  splot fx(2*u,t) + s*cos(v)*cos(q(2*u,t)),\
        fy(2*u,t) + s*cos(v)*sin(q(2*u,t)),\
        1.5*fz(2*u,t) + s*sin(v) w pm3d
}

system("convert -adjoin -delay 10 helix*.png torushelix2.gif")
system("rm helix*.png")