RE: Question on plotting parametric surfaces
- To: mathgroup at smc.vnet.net
- Subject: [mg20893] RE: [mg20880] Question on plotting parametric surfaces
- From: "Ersek, Ted R" <ErsekTR at navair.navy.mil>
- Date: Sat, 20 Nov 1999 01:07:07 -0500 (EST)
- Sender: owner-wri-mathgroup at wolfram.com
ANDRES IGLESIAS PRIETO wrote:
------------------------------
I have a question on plotting surfaces: I have a surface z=f(x,y) and I
would like to plot it over a nonrectangular but arbitrary domain on the
plane X-Y, (for example, suppose such a domain is defined by its boundary,
a set of curves I know). How can I do that?
I already knew that ParametricPlot and ParametricPlot3D can draw parametric
curves and surfaces. But my problem is related to the domain of parametric
surfaces.
Suppose I have the following domain D:
x^2+y^2<=4
and the function
f(x,y)=x^3-y^4+3y-4x+2.
I'd like to display this function only over the given domain, but not over
a rectangular domain, as the ParametricPlot3D does.
--------------------------------------------------------------------
REPLY
I will show how to do this where (x,y) are swapped in f[x,y] because the
graphics look neater that way. I also display it with a hole in the middle.
This is based on a solution in The Mathematica Journal 5(1):15.
The trick is to change variables and reparameterize. Obviously this trick
can be applied to a wide variety of situations.
In[7]:=
f[x_,y_]:=y^3+3x-4y+2
In[14]:=
ParametricPlot3D[{r Cos[ang],r Sin[ang],f[r Cos[ang],r Sin[ang]]},
{r,0.9,4},{ang,0,2Pi},BoxRatios->{1,1,0.4},
ImageSize->{300,300},PlotPoints->{15,30},PlotRange->All];
(* Graphics3D not shown. *)
-------------------
If you don't want to see the mesh use the next line. Wouldn't it be nice if
we could use options Mesh, MeshStyle instead of that damn EdgeForm[] thing.
In[15]:=
ParametricPlot3D[{r Cos[ang],r Sin[ang],f[r Cos[ang],r
Sin[ang]],EdgeForm[]},
{r,0.9,4},{ang,0,2Pi},BoxRatios->{1,1,0.4},
ImageSize->{300,300},PlotPoints->{15,60},PlotRange->All];
--------------------------
He also wrote:
Another interesting thing I'd like to do:
how can I consider restrictions over this domain D, for example, arbitrary
holes? Suppose, for example, that the holes' boundaries are defined by a
set of composite Bezier or b-spline curves.
--------------------------
REPLY
You could do is make Graphics3D primitives for the holes that are the same
color as the background and Show them over the primitives from
ParametricPlot3D.
--------------------
Regards,
Ted Ersek
For Mathematica tips, tricks see
http://www.dot.net.au/~elisha/ersek/Tricks.html