Question: The gridlines in 3dplots

I want to write a procedure for adding gridlines to 3dplots of any function f on ([x_min,x_max]x[y_min,y_max])

restart:
with(plots):
grids:=proc(f,x_min,x_max,y_min,y_max)
 local z_min,z_max,plot_f,xz,yz,xy;
uses plots;
z_min:=0:
z_max:=10:
plot_f:=plot3d(f,x=x_min..x_max,y=y_min..y_max);
xz:=plot3d([x,y_min,z],x=x_min..x_max,z=z_min..z_max,style=line,color=blue,thickness=0,grid=[6,6]);
yz:=plot3d([x_min,y,z],y=y_min..y_max,z=z_min..z_max,style=line,color=blue,thickness=0,grid=[4,6]);
xy:=plot3d([x,y,z_min],x=x_min..x_max,y=y_min..y_max,style=line,color=blue,thickness=0,grid=[4,4]);
return
display(plot_f,xz,yz,xy,lightmodel=none,tickmarks=[3,3,6],labels=[x,y,"f(x,y)"],labeldirections=[horizontal,horizontal,vertical],axes=frame);
end proc:

#EXAMPLE
f:=x^2-y:
x_min:=-1:
x_max:=3:
y_min:=-2:
y_max:=1:
grids(f,-1,3,-2,-1);

 

 

 

 

 

 

Some of the drawbacks of the above code are:

  1. The minimum value ( z_min ) and maximum value ( z_max ) of function f(x,y) can't be calculated automatically.
  2. grid=[6,6],grid=[4,6] etc. can't be calculated automatically. (it may be automatically calculated by considering the stepsize of axis x and axis y)

 

Please Wait...