Re: Re: 3D graphics
- To: mathgroup at smc.vnet.net
- Subject: [mg22799] Re: [mg22720] Re: 3D graphics
- From: "Allan Hayes" <hay at haystack.demon.co.uk>
- Date: Sun, 26 Mar 2000 02:58:48 -0500 (EST)
- References: <8bhvn1$noc@smc.vnet.net>
- Sender: owner-wri-mathgroup at wolfram.com
Comparison of the following postings for time and picture quality suggests that there is some interesting work to be done on this kind of problem. Needs["Graphics`ContourPlot3D`"] f[x_?NumericQ, y_?NumericQ, z_?NumericQ] := If[x^2 + y^2 + z^2 <= 1., 1., 0.] Jens-Peer Kuska: ContourPlot3D[f[x, y, z], {x, -1.1, 1.1}, {y, 0, 1.1}, {z, -1.1, 1.1}, Contours -> {0.5}] // Timing // First 15.98 Second Bojan Bistrovic: ContourPlot3D[f[x, y, z], {x, -1.1, 1.1}, {y, 0, 1.1}, {z, -1.1, 1.1}, Contours -> {0.5}, PlotPoints -> {4, 6}] // Timing // First 95.41 Second Bojan Bistrovic: ContourPlot3D[fun[x, y, z], {x, -1.1, 1.1}, {y, 0, 1.1}, {z, -1.1, 1.1}, Contours -> {0.5}, PlotPoints -> {7, 9}] // Timing//First 1695.88 Second (My machine is clearly much slower than Bojan's) Allan Hayes: f1[p__] := (Plus @@ f @@@ Transpose[{p} + Transpose[{{0, 0, 0}, {d, 0, 0}, {-d, 0, 0}, {0, d, 0}, {0, -d, 0}, {0, 0, d}, {0, 0, -d}}]])/7.0 d = .2; ContourPlot3D[f1[x, y, z] , {x, -1.2, 1.2}, {y, 0, 1}, {z, -1.2, 1.2}, Contours -> {.5}] // Timing // First 18.84 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 "Bojan Bistrovic" <bojanb at python.physics.odu.edu> wrote in message news:8bhvn1$noc at smc.vnet.net... > > Hi, > > > > since your function jump from 0 to 1 you can simply use a > > ContourPlot3D[] with > > contourlevel 1/2 > > > > Needs["ContourPlot3D`"] > > > > fun[x_?NumericQ, y_?NumericQ, z_?NumericQ] := > > If[N[x^2 + y^2 + z^2] < 1., 0., 1.] > > > > > > ContourPlot3D[fun[x, y, z], > > {x, -1.1, 1.1}, {y, -1.1, 1.1}, {z, -1.1, 1.1}, Contours -> {0.5}] > > > > Regards > > Jens > > > > Bernhard Adams wrote: > > > > > > 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 > > > You'll probably wan't to change the default option PlotPoints->{3,5} to get > the better quality of the output. This will naturally increase the time needed > so be careful: > > In[10]:= ContourPlot3D[fun[x, y, z], > {x, -1.1, 1.1}, {y, -1.1, 1.1}, {z, -1.1, 1.1}, Contours -> {0.5}]//Timing > > Out[10]= {4.21 Second, - Graphics3D - } > > In[11]:= ContourPlot3D[fun[x, y, z], > {x, -1.1, 1.1}, {y, -1.1, 1.1}, {z, -1.1, 1.1}, Contours -> {0.5}, > PlotPoints->{4,6}]//Timing > > Out[11]= {18.48 Second, - Graphics3D - } > > This one is alreasy recognisable as sphere, but it's still far from perfect: > > In[12]:= ContourPlot3D[fun[x, y, z], > {x, -1.1, 1.1}, {y, -1.1, 1.1}, {z, -1.1, 1.1}, Contours -> {0.5}, > PlotPoints->{5,7}]//Timing > > Out[12]= {56.83 Second, - Graphics3D - } > > In[13]:= ContourPlot3D[fun[x, y, z], > {x, -1.1, 1.1}, {y, -1.1, 1.1}, {z, -1.1, 1.1}, Contours -> {0.5}, > PlotPoints->{6,8}]//Timing > > Out[13]= {145.6 Second , - Graphics3D - } > > One that looks good is > > In[14]:= ContourPlot3D[fun[x, y, z], > {x, -1.1, 1.1}, {y, -1.1, 1.1}, {z, -1.1, 1.1}, Contours -> {0.5}, > PlotPoints->{7,9}]//Timing > > Out[13]= {278.31 Second, , - Graphics3D - } > > Bye, Bojan > > -- > --------------------------------------------------------------------- > Bojan Bistrovic, bojanb at jlab.org > Old Dominion University, Norfolk VA & Jefferson Lab, Newport News, VA > --------------------------------------------------------------------- > >
- Follow-Ups:
- Re: Re: Re: 3D graphics
- From: Hartmut Wolf <hwolf@debis.com>
- Re: Re: Re: 3D graphics