Trefoil Knot
>u:=linspace(-pi,pi,160); v:=linspace(-pi,pi,400)'; ...
x:=(4*(1+.25*sin(3*v))+cos(u))*cos(2*v); ...
y:=(4*(1+.25*sin(3*v))+cos(u))*sin(2*v); z=sin(u)+2*cos(3*v); ...
plot3d(x,y,z,frame=0,scale=1.5,hue=1,light=[1,0,-1],zoom=3.5):

>plot3d(x,y,z,frame=0,scale=1.5,hue=1,light=[1,0,-1],anaglyph=1,zoom=3.5):

>x:=(4*(1+.4*sin(5*v))+cos(u))*cos(2*v); ...
y:=(4*(1+.4*sin(5*v))+cos(u))*sin(2*v); z=sin(u)+2*cos(5*v); ...
plot3d(x,y,z,frame=0,scale=1.5,hue=1,light=[1,0,-1], ...
zoom=3,anaglyph=1):

>function fx (t) &= 4*(1+sin(3*t)/3)*sin(2*t)
sin(3 t)
4 sin(2 t) (-------- + 1)
3
>function fy (t) &= 4*(1+sin(3*t)/3)*cos(2*t)
sin(3 t)
4 cos(2 t) (-------- + 1)
3
>t=linspace(-pi,pi,400); ...
plot2d(fx(t),fy(t),r=5):

>function fz(t) &= 2*cos(3*t)
2 cos(3 t)
>plot3d(fx(t),fy(t),fz(t),wire=1,>user,zoom=4,<frame, ...
title=" Press cursor keys, a, space, or return."):

>function f(t) &= [fx(t),fy(t),fz(t)]
sin(3 t) sin(3 t)
[4 sin(2 t) (-------- + 1), 4 cos(2 t) (-------- + 1),
3 3
2 cos(3 t)]
>function df(t) &= diff(f(t),t)
sin(3 t)
[8 cos(2 t) (-------- + 1) + 4 sin(2 t) cos(3 t),
3
sin(3 t)
4 cos(2 t) cos(3 t) - 8 sin(2 t) (-------- + 1), - 6 sin(3 t)]
3
>function w1(t) &= [df(t)[2],-df(t)[1],0]
sin(3 t)
[4 cos(2 t) cos(3 t) - 8 sin(2 t) (-------- + 1),
3
sin(3 t)
- 8 cos(2 t) (-------- + 1) - 4 sin(2 t) cos(3 t), 0]
3
>function w2(t) &= crossproduct(df(t),w1(t));
>function g(s,t,r) &= f(t)+r*(cos(s)*w1(t)/norm(w1(t))+sin(s)*w2(t)/norm(w2(t)));
>function gx(s,t) &= g(s,t,r)[1];
>function gy(s,t) &= g(s,t,r)[2];
>function gz(s,t) &= g(s,t,r)[3];
>s=linspace(pi,-pi,160)';
>r=1;
>plot3d(gx(s,t),gy(s,t),gz(s,t),>hue,<frame,zoom=4,max=0.7,amb=0):

>load povray;
>pov3d(gx(s,t),gy(s,t),gz(s,t),zoom=5,axis=0, ...
look=povlook(gray,>phong),aspect=1.2);

>pov3d(gx(s,t),gy(s,t),gz(s,t),zoom=5,axis=0, ...
look=povlook(gray,),aspect=1.2,>anaglyph);

>povclear();
Examples Homepage