--Copyright The Numerical Algorithms Group Limited 1991.

)cl all

-- Create a (p,q) torus-knot with radius around the curve of r.

torusKnot(p,q,r) ==
  a := 1
  b := 1
  ab := a+b
  fac := 2*ab/(1.1*ab-sin(q*t))
  Title := concat("Torus Knot of Type (", concat(string p, 
                  concat(",", concat(string q, ")"))))
  Curve := curve(a*fac*cos(p*t), a*fac*sin(p*t), b*fac*cos(q*t))
  r = 0 => draw(Curve, t=0..2*%pi, title == Title)
  draw(Curve, t=0..2*%pi, tubeRadius == r, title == Title)

torusKnot(2, 3, 0.3)
