MathGroup Archive 2004

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

Search the Archive

Re: Re: Re: Conditinal Plots

  • To: mathgroup at smc.vnet.net
  • Subject: [mg51148] Re: [mg51122] Re: [mg51037] Re: Conditinal Plots
  • From: "David Park" <djmp at earthlink.net>
  • Date: Wed, 6 Oct 2004 04:34:30 -0400 (EDT)
  • Sender: owner-wri-mathgroup at wolfram.com

DrawGraphics from my web site has the ability to do this kind of thing. Here
is an example.

Needs["DrawGraphics`DrawingMaster`"]

f[x_, y_] := Sin[3 Sqrt[x^2 + y^2]]/Sqrt[x^2 + y^2]

grid = N[MakePolyGrid[{41, 41}, {{-Pi, -Pi}, {Pi, Pi}}]];

trimmedgrid = TrimPolygons[#1^2 + #2^2 & , {-1, Pi^2}][grid];

MakePolyGrid creates a 2D grid of rectangular polygons.
TrimPolygons trimes the Polygons according to whether they exceed the limits
(the second parameter) of a function (the first parameter).

In the above case, the grid is trimmed to a circle. The following displays
it.

Draw2D[
    {MediumAquamarine,
      trimmedgrid,
      trimmedgrid // PolygonOutline[Black]},
    AspectRatio -> Automatic,
    Background -> Linen];

We can then plot the function in 3D by raising the trimmed grid to a 3D
surface as with the following statement.

Draw3DItems[
    {SurfaceColor[MediumAquamarine],
      EdgeForm[ColorMix[MediumAquamarine, Black][0.4]],
      trimmedgrid // RaiseTo3D[f]},
    NeutralLighting[0.3, 0.5, 0.1],
    PlotRange -> {-1, 3},
    BoxRatios -> {1, 1, 1/2},
    BoxStyle -> Gray,
    ViewPoint -> {1.737, -2.778, 0.845},
    Background -> Linen,
    ImageSize -> 450];

NeutralLighting inserts a series of Lighting options that tone down the
color saturation of the lights so surface colors will better display. I used
EdgeForm to make the edges a darker shade of the surface color.

David Park
djmp at earthlink.net
http://home.earthlink.net/~djmp/



From: Garry Helzer [mailto:gah at math.umd.edu]
To: mathgroup at smc.vnet.net

I missed the original posting by philippe so I don't know the precise
question or philippe's email address.

Clipping a graphic to one side of a plane is a basic computational
geometry task but it is considered rather low level and Mathematica has
no user level function that will do the clipping.  With such a function
one could plot the graphic over a sufficiently large domain and then
clip by the vertical planes over the polygon edges.

The lecture notes on Geometry for Computer Graphics at

http://www.math.umd.edu/~gah/

contain an algorithm for such clipping  which is implemented in the
accompanying package Peano.m. However the implementation is for show
rather than go?and slow. Further, the mathematics used is not widely
known and some study of the lecture notes would be necessary before the
function could be used with confidence (the trivector defining the
plane is one of the arguments).

The more general question of clipping  a graphic at a surface is
addressed in the article "Clipping Polygons" in The Mathematica
Journal, volume 8, number 4. That article contains an illustration of a
surface ( a monkey saddle) plotted over a rectangle, then clipped by
the cylinder over the circle x^2+y^2=1. Unfortunately, when the issue
is downloaded the package with the clipping function is not included.
The package works under version 4 but needs modification to work under
version 5 because of a syntax change to the function FindRoot. I intend
to produce a version 5 form of the package but will not be able to do
so for several months.

On Oct 2, 2004, at 3:18 AM, philippe wrote:

> If you really want to trim your plot with a cylinder you can try to
> adapt the principle which is present in the "SurfaceColor" example in
> the help browser.
> To get the line drawn on the surface, first convert your plot to a
> generic graphics (Graphics[....]), then type %//InputForm.
> You will have the internal structure of the graphic. Then, with
> replacement rules, you can keep only the part you are interested in.
> You can try something like that.
>
>
>
> On 3 Sep 04 11:04:27 -0400 (EDT), matt wrote:
>> Dear all,
>>
>> Í´m trying to produce a 3D plot with a 2D ploygon (within unit
> circle)
>> as its base. Equivalently, I want my 3D surface to sit inside (be
>> bounded by) a cylinder with n-gon cross section.
>>
>> How can I trim off the edges?
>> I´ve tried to use
>> If[ (condition), Plot, Blah] but it doesn´t seem to work.....
>
>
Garry Helzer
gah at math.umd.edu




  • Prev by Date: Re: normal distribution random number generation
  • Next by Date: Re: Conveniently Restarting Notebooks
  • Previous by thread: Re: Re: Conditinal Plots
  • Next by thread: Re: ListPlot3D with holes