MathGroup Archive 2001

[Date Index] [Thread Index] [Author Index]

Search the Archive

RE: i don't want intersection


My DrawingCube package, available at my web site, has a routine
DrawContourLines which will do what your wish. There is also a tutorial and
examples of using DrawContourLines in Section 3, DrawingCube Package
Routines, DrawContourLines. You have to define the function as f[x,y]:=...,
and then use that in the routine. There is also an option DrawContourOffset
which allows you to offset the contours slightly, in any direction, so as to
avoid intersections. If you use enough plot points for both the surface and
the contour lines you can usually get a fairly snug fit without

If you wish to do it yourself you essentially have to do a ContourPlot,
convert the output to Graphics, extract the contour lines, and then add the
z value to each point. Then add a small offset to each point. Then combine
the lines with a plot of the surface. It is a lot easier with DrawingCube
because the package is designed to make it easy to combine various elements
into one piece of graphics.

Here is a sample piece of code, using the package, that draws contour lines
on the surface
Sin[x y]. Sometimes it looks nicer to turn the Lighting off and color the
surface with a uniform color. That's what I did here. You definitely want to
use EdgeForm[] to get rid of polygon edges because they will interfere with
the contour lines.


f[x_, y_] := Sin[x y]

 {EdgeForm[], LightBlue,
  Draw3D[f[x, y], {x, -Pi/2, Pi/2},
      {y, -Pi/2, Pi/2}, PlotPoints -> 31],
  DrawContourLines[f[x, y], {x, -Pi/2, Pi/2}, {y, -Pi/2, Pi/2},
      Contours -> Range[-1, 1, 0.05], DrawContourOffset -> {0, 0, 0.01},
      PlotPoints -> 31]}],
   AspectRatio -> Automatic,
   PlotRange -> All, {ImageSize -> 450, Lighting -> False}];

David Park
djmp at

> From: Borut L [mailto:borut at]
To: mathgroup at
> Good day,
> I made a function which displays 3D contour lines onto Surface Graphics.
> It's pretty neat. There is a problem though. The contours "fit"
> so perfecty
> onto the surface that they [are] a part of the surface - so half visible
> half hidden by the surface - they seem to intersect.
> I also came across an article in old Mathematica Journal which
> explains the
> method and also mentions the problem but do not address it in details.
> So I ask you mighty Mathematicians if you know a simple solution. ?
> Is there even simpler way to make 3D contours... please point me to an
> eventual news thread. ?
> Thanks a lot,
> Borut Levart,
> a physics student from Slovenia

  • Prev by Date: Re: How to make curved arrows?
  • Next by Date: Re: Replacing Parts of a List
  • Previous by thread: i don't want intersection
  • Next by thread: Re: i don't want intersection