On Jul 12, 2:28 am, David Sanders <dpsand...@gmail.com> wrote:
> Hi,
>
> I have been playing around with the implicit_plot3d command, and it's
> very nice.
>
> Is there something similar to plot regions defined by inequalities in
> 3D, along the lines of the Mathematica
> RegionPlot3D command?  I see that there is an old discussion from 2
> years ago about this.
>
> It seems to me (in my ignorance) that the kind of algorithm required
> to do this should not be too different from that for implicit_plot3d
> with the region option. (Though implicit_plot3d draws surfaces,
> whereas region_plot3d would draw volumes. But apparently the marching
> cubes algorithm is used for both?)

I haven't looked at this stuff in more than a year, but I think this
is all accurate:

Our plotting framework doesn't really "understand" volumes, only
surfaces.  So it would be a major overhaul to produce a plot that
showed (via some sort of volumetric shading, say) the difference
between the "inside" and the "outside" of your region.

However, if you want to produce a plot of the surface of your region,
that's pretty easy.  If your region is defined by a single inequality
F(x,y,z)<0, then you can just implicit_plot3d F(x,y,z).  If your
region is defined as a boolean combination of inequalities, then
arrange all the inequalities to be of the form F(x,y,z) < 0, then drop
all the "< 0", replace "and" with "max_symbolic", replace "or" with
"min_symbolic", and replace "not F(x,y,z)" with "-F(x,y,z)".  Also,
when you plot, because of http://trac.sagemath.org/sage_trac/ticket/9483
you need to add "smooth=False".

Here's a complete example.  This forms the intersection between a cube
and the union of two cylinders.

sage: var('x,y,z')
(x, y, z)
sage: implicit_plot3d(max_symbolic(min_symbolic(x*x+y*y-1, x*x+z*z-2),
x-1.8, y-1.8, z-1.8, -x-1.8, -y-1.8, -z-1.8), (x, -2, 2), (y, -2, 2),
(z, -2, 2), smooth=False)

It would be great to put all of this into a region_plot3d command, but
as far as I know, Sage does not yet support symbolic conjunctions and
disjunctions ("and"s and "or"s); so it would be difficult to tell
region_plot3d about any region more complicated than a single
inequality.

Carl

-- 
To post to this group, send email to sage-support@googlegroups.com
To unsubscribe from this group, send email to 
sage-support+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sage-support
URL: http://www.sagemath.org

Reply via email to