MathGroup Archive 2000

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

Search the Archive

Re: 3D graphics

  • To: mathgroup at smc.vnet.net
  • Subject: [mg22728] Re: 3D graphics
  • From: "Allan Hayes" <hay at haystack.demon.co.uk>
  • Date: Fri, 24 Mar 2000 03:27:12 -0500 (EST)
  • References: <8b9n2b$98i@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

"Bernhard Adams" <adams at hasyl01.desy.de> wrote in message
news:8b9n2b$98i at smc.vnet.net...
> Hi everybody,
>
> I would like to plot a body in 3D whose volume is defined by a function
> f[x,y,z] which returns 1 if (x,y,z) is inside the body and 0 if outside.
> How to plot this?
>
> Thanx, Bernhard Adams

Bernhard:

Let's see what we can do with a sphere.

f[x_, y_, z_] :=
  If[x^2 + y^2 + z^2 < 1, 1., 0.]

using

<< Graphics`ContourPlot3D`

We need to get a function that ContourPlot3D can work on: one that defines
the surface as a contour - at least approximately.
Here are two experiments:

1. Take the mean over neighboring points,

f1[p__] :=
  (Plus @@
      f @@@ Transpose[{p} +

nspose[ 
              {{0, 0, 0}, {.1, 0, 0}, {-.1, 0, 0}, {0, .1, 0},
               {0, -.1, 0}, {0, 0, .1},{0, 0, -.1}}
              ]]) / 7.0

ContourPlot3D[f1[x, y, z] - .5,
    {x, -1.2, 1.2}, {y, 0, 1}, {z, -1.2, 1.2}] // Timing//First

        15.71 Second

2. Use FunctionInterpolation.

f2 = FunctionInterpolation[
        f[x, y, z], {x, -1.2, 1.2}, {y, 0, 1}, {z, -1.2, 1.2},
        InterpolationOrder -> 1]; // Timing//First

        2.75 Second

ContourPlot3D[f2[x, y, z] - .5,
    {x, -1.2, 1.2}, {y, 0, 1}, {z, -1.2, 1.2}] // Timing//First

        17.52 Second


Allan
---------------------
Allan Hayes
Mathematica Training and Consulting
Leicester UK
www.haystack.demon.co.uk
hay at haystack.demon.co.uk
Voice: +44 (0)116 271 4198
Fax: +44 (0)870 164 0565
     








  • Prev by Date: Re: pattern in list of derivatives
  • Next by Date: Re: FindMinimum
  • Previous by thread: Re: 3D graphics
  • Next by thread: Re: Re: 3D graphics