[Date Index]
[Thread Index]
[Author Index]
Re: plot3D over a triangular domain
*To*: mathgroup at smc.vnet.net
*Subject*: [mg58014] Re: [mg57984] plot3D over a triangular domain
*From*: "David Park" <djmp at earthlink.net>
*Date*: Thu, 16 Jun 2005 05:36:44 -0400 (EDT)
*Sender*: owner-wri-mathgroup at wolfram.com
Tun Myint,
The DrawGraphics package at my web site below has two methods for making
plots over triangular, or many other, domains.
Needs["DrawGraphics`DrawingMaster`"]
f[x_, y_] := Sin[2x]Cos[2y]
The first method uses IteratorSubstitution to substitute a new variable w
for y and then reparametrize the function so that w has fixed limits.
IteratorSubstitution[{x, y, f[x, y]},
{y, (1/2)*(x - 1), (1/2)*(1 - x)}]//Simplify
{{x, (-(1/2))*(-1 + 2*w)*(-1 + x), Cos[(-1 + 2*w)*(-1 + x)]*
Sin[2*x]}, {w, 0, 1}}
Notice that I obtained an expression for {x, y, f[x,y]}. We can then use
ParametricPlot3D to directly plot the surface.
ParametricPlot3D[{x, (-(1/2))*(-1 + 2*w)*(-1 + x),
Cos[(-1 + 2*w)*(-1 + x)]*Sin[2*x]}, {x, -1, 1},
{w, 0, 1}, PlotPoints -> {25, 15},
ViewPoint -> {-0.836, -2.556, 2.054},
AxesLabel -> {x, y, ""}, ImageSize -> 450];
The following does the same plot using the DrawGraphics routines
Draw3DItems, ParametricDraw3D, ColorMix and NeutralLighting. This allows us
to color the surface and subdue the 'mesh' lines.
Draw3DItems[{SurfaceColor[LightSteelBlue],
EdgeForm[ColorMix[LightSteelBlue, Black][0.5]],
ParametricDraw3D[{x, (-(1/2))*(-1 + 2*w)*(-1 + x),
Cos[(-1 + 2*w)*(-1 + x)]*Sin[2*x]}, {x, -1, 1},
{w, 0, 1}, PlotPoints -> {25, 15}]},
ViewPoint -> {-2.278, -2.142, 1.294},
NeutralLighting[0.3, 0.5, 0.1, 5*Degree],
BoxRatios -> {1, 1, 1}, BoxStyle -> Gray,
PlotLabel -> f[x, y], Background -> Linen,
ImageSize -> 450];
The second method is to use what I call a HollisGrid, devised by Selwyn
Hollis. It will divide up any star-like or convex region into more or less
equal area polygons. The region can be defined by vertices or by a curve.
Here we use vertices that define your triangular region. I plot the grid so
we can see what it looks like.
vertices = {{-1, -1}, {1, 0}, {-1, 1}};
grid = HollisGrid[vertices, GridExtraSmoothing -> True];
Draw2D[
{Line /@ grid},
AspectRatio -> Automatic,
Frame -> True,
PlotRange -> {{-1, 1}, {-1, 1}},
Background -> Linen,
ImageSize -> 350];
We can then raise the grid to a 3D surface.
Draw3DItems[{SurfaceColor[Melon],
EdgeForm[ColorMix[Melon, Black][0.4]],
RaiseTo3D[f][Polygon /@ grid]},
NeutralLighting[0.3, 0.5, 0.1, 85*Degree],
BoxRatios -> {1, 1, 1/2},
BoxStyle -> Gray,
ViewPoint -> {-1.014, -2.149, 2.409},
PlotLabel -> f[x, y],
Background -> ColorMix[Peacock, White][0.8],
ImageSize -> 450];
David Park
djmp at earthlink.net
http://home.earthlink.net/~djmp/
From: Tun Myint Aung [mailto:TMA at nus.edu.sg]
To: mathgroup at smc.vnet.net
Hi All,
I would like to plot a function over a isosceles triangular domain.
I mean Plot3D[function, {x,-1,1},{y, -0.5+0.5x, 0.5-0.5x}]. But I got
message that the limit must be real number. Anyone can help me?
Best Regards,
Tun Myint Aung
Graduate Student
National University of Singapore
E1A #02-18
E-mail g0202015 at nus.edu.sg <mailto:g0202015 at nus.edu.sg>
Prev by Date:
**Re: For Loop and Array related**
Next by Date:
**Re: problem with InverseLaplaceTransform**
Previous by thread:
**Plot3D over a triangular domain**
Next by thread:
**Plot difficulties <Error Machine Sized Real Number>**
| |