# Plot a function f: [0,1] -> [0,1] on a torus by plotting # the angle 2*Pi*t vs 2*Pi*f(t). It's better with your own # maple, so download the code and run it yourself if you can. f := t -> 4*t*(1-1/t): # the `mod 1' is implicit rho := 3: # radius to the centre of the doughnut hole b := 1: # radius to the centre of the doughnut r := 1.1: # *just* bigger than b (hidden line alg) centreline := [ rho*cos(2*Pi*t), rho*sin(2*Pi*t), 0, radius=b]: curveqn := [ (rho - r*cos(2*Pi*f(t)))*cos(2*Pi*t), (rho - r*cos(2*Pi*f(t)))*sin(2*Pi*t), -r*sin(2*Pi*f(t)) ]: curvplt := plots[spacecurve]( curveqn, t=0..1, thickness=2, numpoints=101, colour=red, thickness=4, view=[-4.4..4.4, -4.4..4.4, -2.2..2.2]): torplt := plots[tubeplot]( centreline, t=0..1, tubepoints=20, view=[-4.4..4.4, -4.4..4.4, -2.2..2.2], style=PATCH, colour=cyan): plots[display]({curvplt, torplt});