Re: how to draw the contour lines on a surface
- To: mathgroup at smc.vnet.net
- Subject: [mg3931] Re: how to draw the contour lines on a surface
- From: ianc (Ian Collier)
- Date: Fri, 10 May 1996 03:29:55 -0400
- Organization: Wolfram Research, Inc.
- Sender: owner-wri-mathgroup at wolfram.com
In article <4m7q96$k5h at dragonfly.wolfram.com>, goffinet <goffinet at cit-novell.univ-st-etienne.fr> wrote: > Hello > > I'm sure the answer lies somewhere inthe Mathematica journal, but I > have been unable to find it > > I want to get an image of a surface (with z=z(x,y) would be a good > start, with an implicit surface it would be even better) with the lines > z=Constant drawn on it. I don't want to Solve différential equations or > such, merely to make use of what is already done in ContourPlot (or > ImplicitPlot) and to draw the lines on the surface > > How can one get the Lines[... , ... , ] which are used by the > final display of a ContourPlot? > Tom Wickham-Jones describes several methods for forming contour lines in 3 dimensions in his book "Mathematica Graphics: Techniques & Applications" (TELOS/Springer Verlag 1994). This example, taken from pages 276-277 of that book, illustrates one method. First we define a function and create contour and surface plots of it. In[1]:= fun[x_, y_ ] := x y In[2]:= c = ContourPlot[ fun[x, y], {x, -2,2},{y,-2,2}, ContourShading -> False] Out[2]= -ContourGraphics- In[3]:= s = Show[ SurfaceGraphics[c]] Out[3]= -SurfaceGraphics- Now it is converted to a Graphics object. The lines are converted to three-dimensional lines by taking each point and appending the value of the function at that point. In[5]:= c3d = First[ Graphics[c]] /. Line[pts_] :> (val = Apply[fun, First[pts]]; Line[Map[Append[#, val]&, pts]]); In[6]:= Show[Graphics3D[c3d]] Out[6]= -Graphics3D- Finally we show the lines together with the surface. In[7]:= Show[s, %] Out[7]= -Graphics3D- There are a number of ways that this could be enhanced. For a more detailed discussion I would strongly recommend that you take a look at Tom Wickham-Jones' book. I hope this helps. --Ian ----------------------------------------------------------- Ian Collier Wolfram Research, Inc. ----------------------------------------------------------- tel:(217) 398-0700 fax:(217) 398-0747 ianc at wolfram.com Wolfram Research Home Page: http://www.wolfram.com/ ----------------------------------------------------------- ==== [MESSAGE SEPARATOR] ====