Re: Re: 3D graphics
- To: mathgroup at smc.vnet.net
- Subject: [mg22793] Re: [mg22720] Re: 3D graphics
- From: Bojan Bistrovic <bojanb at python.physics.odu.edu>
- Date: Sat, 25 Mar 2000 03:58:31 -0500 (EST)
- Sender: owner-wri-mathgroup at wolfram.com
> 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 ---------------------------------------------------------------------