Mathematical Principles for Scientific Computing and Visualization
http : // www.farinhansford.com/books/scv
by Gerald Farin and Dianne Hansford

This notebook demonstrates some elements of contour computation using the marching squares method. 

Here we plot a simple function, z=xy, over [-1,1]x[-1,1] and show its intersection with three different planes: z=-0.2, z=0, and z=0.2.  At the edges of the surface patch, the intersection points with the planes are identical, but the connectivity of the intersection points differs. This is one the big challenges with the marching squares method. (And also a challenge with the marching cubes method in 3D.)

Also demonstrated in this notebook is a contour plot of z=xy. Each of the "contours" produced by intersecting the surface with a plane is visible in the multi-level contour plot.

Figures  14.17 was created with this notebook.

See Chapter 14 : Visualizing Scalar Values over 2D for details.

Updated May 2008

(* Set the output folder *)
SetDirectory[ToFileName[Extract["FileName"/.NotebookInformation[EvaluationNotebook[]],{1},FrontEnd`FileName]]];

(* Define a hyperbolic paraboloid *)
f[x_,y_]=x y;

(* Create three plane equations *)
(* z = -0.2,  z=0, and z=0.2 *)
planeneg[x_,y_]=-0.2;
planezero[x_,y_]=0.0;
planepos[x_,y_]=0.2; 


(* Create a plot of the hyperbolic paraboloid over [-1,1] *)plot1=Plot3D[f[x,y],{x,-1,1},{y,-1,1},Mesh->True,PlotPoints->25,PlotStyle->Directive[Orange,Specularity[White,100]],BaseStyle->{"FontFamily"->"Helvetica","FontSize"->11}]

(* Create (separate) plots of the three planes *)
plot2=Plot3D[planepos[x,y],{x,-1,1},{y,-1,1},Mesh->False,PlotPoints->2,PlotStyle->Directive[Green,Specularity[White,10]],BaseStyle->{"FontFamily"->"Helvetica","FontSize"->11}];

plot3=Plot3D[planezero[x,y],{x,-1,1},{y,-1,1},Mesh->True,PlotPoints->2,PlotStyle->Directive[Green,Specularity[White,10]],BaseStyle->{"FontFamily"->"Helvetica","FontSize"->11}];

plot4=Plot3D[planeneg[x,y],{x,-1,1},{y,-1,1},Mesh->False,PlotPoints->2,PlotStyle->Directive[Green,Specularity[White,10]],BaseStyle->{"FontFamily"->"Helvetica","FontSize"->11}];

(* Pair the hyperbolic paraboloid surface with each of the three planes, creating three plots *)

Picture1=Show[{plot1,plot2},PlotRange->{{-1,1},{-1,1},{-2,2}}]

Picture2=Show[{plot1,plot3},PlotRange->{{-1,1},{-1,1},{-2,2}}]

Picture3=Show[{plot1,plot4},PlotRange->{{-1,1},{-1,1},{-2,2}}]

(* Output to a postscript file *)
(*
Export["contourxy_posplane.eps",Picture1];
Export["contourxy_zeroplane.eps",Picture2]; 
Export["contourxy_negplane.eps",Picture3]; 
*)


(* Create a contour plot of the hyperbolic paraboloid *)contplot=ContourPlot[f[x,y],{x,-1,1},{y,-1,1},Contours->15,ContourShading->False]