Surface

443 days ago by ketchers

The first example plots level curves of f(x,y)=z for "contour" many fixed values of z and then plots the surface alond with level curves associated to fixing y (blue) and x (red). You can control the number level curves via the variables "gridlines" and "contours". 

reset() var('x,y,t') @interact def _(f=x*y^2/(x^2+y^4),xmin=-2,xmax=2,ymin=-2,ymax=2,gridlines=10,contours=10): P=plot3d(f,(x,xmin,xmax),(y,ymin,ymax),opacity=.7,color=(.7,.7,.7)) for i in [xmin..xmax,step=(xmax-xmin)/gridlines]: P+=parametric_plot3d((i,t,f(x=i,y=t)),(t,ymin,ymax),color="red") for i in [ymin..ymax,step=(ymax-ymin)/gridlines]: P+=parametric_plot3d((t,i,f(x=t,y=i)),(t,xmin,xmax),color="blue") Q=contour_plot(f,(x,xmin,xmax),(y,ymin,ymax),colorbar=True,axes=True,labels=True,contours=contours) show(Q);show(P) 
       

Click to the left again to hide and once more to show the dynamic interactive window

The next example plots level surfaces of f(x,y,z)=w. Choose different values for w and see how the level surfaces change. More interesting surfaces, choices of f, can be found at here.

reset() var('x,y,z') @interact def _(w=0,f = (x^2 + y^2 + z^2 - 1)^2 - ((z - 1)^2 - 2*x^2)*((z + 1)^2 - 2*y^2),min=-2,max=2): P=implicit_plot3d(f==w,(x,min,max),(y,min,max),(z,min,max)) html('$f(x,y,x)\;=\;%s\;=\;%s'%(latex(f),w)) show(P) 
       

Click to the left again to hide and once more to show the dynamic interactive window

The next example is a function f:\mathbb R^2\to\mathbb R^3 giving a Möbius strip. The functions is

f(s,t)=(R-s\sin(t/2))(\cos(t),\sin(t),0)+s\cos(t/2)(0,0,1)

You can get an idea of how the surface forms by setting t0 ti a value between 0 and 2\pi.

var('s,t') R=5 @interact def mobius(t0=[0..2*pi,step=pi/4]): x=R*cos(t)-s*sin(t/2)*cos(t) y=R*sin(t)-s*sin(t/2)*sin(t) z=s*cos(t/2) f=vector([x,y,z]) P=parametric_plot(f,(s,-1.5,1.5),(t,0,2*pi),opacity=.7) P+=line((f(t=t0,s=-1.5),f(t=t0,s=1.5)),thickness=2,color='green') P+=sphere(f(t=t0,s=-1.5),.1,color='yellow') P+=sphere(f(t=t0,s=1.5),.1,color='red') P+=parametric_plot(f(s=-1.5),(t,-0.0001,t0),color='yellow',thickness=3) P+=parametric_plot(f(s=1.5),(t,-.0001,t0),color='red',thickness=3) show(P) 
       

Click to the left again to hide and once more to show the dynamic interactive window