RE: Re: Plotting bounded domains
- To: mathgroup at smc.vnet.net
- Subject: [mg23262] RE: [mg23211] Re: [mg23110] Plotting bounded domains
- From: "David Park" <djmp at earthlink.net>
- Date: Sat, 29 Apr 2000 22:05:04 -0400 (EDT)
- Sender: owner-wri-mathgroup at wolfram.com
> From: Hartmut Wolf [mailto:hwolf at debis.com] To: mathgroup at smc.vnet.net > > I would like to add two methods: > > (1) define f as: > > f[x_, y_] := x*y /; 0 <= y <= x > f[_, _] = Null > > Off[Plot3D::"plnc", Plot3D::"gval"] > > Plot3D[f[x, y], {x, 0, 2}, {y, 0, 2}] > > > (2) manipulate the output > > g = Graphics3D[ > Plot3D[x*y, {x, 0, 2}, {y, 0, 2}, DisplayFunction -> Identity]]; > > g2 = g /. p : Polygon[_] :> (p /. {x_, y_, z_} -> > If[y <= x, {x, y, z}, Unevaluated[Sequence[]]]); > > Show[g2, DisplayFunction -> $DisplayFunction] > > I consider the result (2) as most pleasing. > > > Kind regards, Hartmut > Hi Hartmut, Your second solution is nice - for the particular case at hand. The plot looks nice because the remaining points all lie right on the desired boundary. But now suppose that you wish to plot the same function in the region 0 < y < Sqrt[x]? The method will again produce an irregular edge. The method I proposed will always produce a smooth edge. Here it is for the new case. Needs["Graphics`DrawingCube`"] IteratorSubstitution[x*y, {y, 0, Sqrt[x]}] {w*x^(3/2), {w, 0, 1}} Show[Graphics3D[{Draw3D[w*x^(3/2), {x, 0, 2}, {w, 0, 1}] /. DrawingTransform3D[Function[{x, w, z}, x], Function[{x, w, z}, w*Sqrt[x]], Function[{x, w, z}, z]]}], Axes -> True, AxesLabel -> {x, y, z}]; The idea of using a substitution of variable to obtain a fixed range iterator, and smooth boundaries, is not a new idea. I can't remember or find where I read it, probably in an old Mathematica Journal, and can't give proper credit to whomever showed how to do it in Mathematica. What I did was provide some convenient routines to implement it in DrawingCube. This is really a very common problem when trying to piece together 3D graphics objects. David Park djmp at earthlink.net http://home.earthlink.net/~djmp/