> # cross section examples > # sfb jan 30, 2003 > with(plots); > # we are going to use the animate command which is not very powerful. Later we will show how to animate by hand. > f:=x^2-y^2;#f:=x*y; > L:=3; > title1:=cat("3D plot of ",convert(f,string)); > plot3d(f,x=-L..L,y=-L..L,title=title1,style=wireframe,axes=boxed,shading=zhue); > titlex:=cat("animation of x = c cross sections ",convert(f,string)); > animate(f,y=-L..L,x=-L..L,title=titlex);# plots of f(c,y) > titley:=cat("animation of y = c cross sections ",convert(f,string)); > animate(f,x=-L..L,y=-L..L,title=titlex);# plots of f(x, c) > g:=eval(f,{x=r*cos(t),y=r*sin(t)});#convert to polar coordinates > titlepolar:=cat("polar view of ",convert(f,string)); > #cylinderplot(g,r=0..L,t=0..2*Pi); > #cylinderplot(g,t=0..2*Pi,r=0..L); > plot3d([r*cos(t),r*sin(t),g],r=0..L,t=0..2*Pi,title=titlepolar); > titletheta:=cat("animation of theta = c cross sections ",convert(f,string)); > animate(g,r=-L..L,t=0..2*Pi,title=titletheta); > # > # Now with more advanced techniques > # > background:=plot3d(f,x=-L..L,y=-L..L,style=wireframe,shading=z,axes=boxed): > background; > for i from 1 to 21 do thisx:=-L+(i-1)*L/10: P[i]:=display(background, > spacecurve([thisx,y,eval(f,{x=thisx})],y=-L..L,thickness=3,color=black)):od: > display(seq(P[i],i=1..21),insequence=true); > # > polarbackground :=plot3d([r*cos(t),r*sin(t),g],r=0..L,t=0..2*Pi,style=wireframe,shading=z,axes=boxed): > polarbackground; > for i from 1 to 21 do thist:=(i-1)*2*Pi/20: P[i]:=display(polarbackground, > spacecurve([r*cos(thist),r*sin(thist),eval(g,{t=thist})],r=0..L,thickness=3,color=black)):od: > display(seq(P[i],i=1..21),insequence=true); >