#5514: [with patch, needs work] implement exclusions for parametric 3d plots
-------------------------+--------------------------------------------------
Reporter: wcauchois | Owner: wcauchois
Type: enhancement | Status: new
Priority: major | Milestone: sage-4.0
Component: graphics | Keywords:
-------------------------+--------------------------------------------------
Comment(by jason):
You're right that it is really choppy. I had a go at it: apply trac-5514
-region-function.patch instead of the first patch.
This implements region_function for indexed face sets, as well as a
specialized version for parametric surfaces. The nice thing about making
it available for indexed face sets is that *any* surface can use it now,
and it will be easier after some more glue code is written.
To encourage reviews, here is what is possible (and it looks a lot
smoother now; I don't just delete faces, I just delete bad vertices and
redefine faces):
{{{
We use a region function to plot a figure with a circular region (in
u,v coordinates) excluded
from its center::
sage: u, v = var('u, v')
sage: parametric_plot3d([u, v*u, u^2 + v^2], (u, -2, 2), (v, -2,
2), region_function=lambda u,v: u^2+v^2>3, plot_points=(150,150))
Plot part of a sphere (using spherical coordinates):
sage: theta, phi = var('theta, phi')
sage: p=parametric_plot3d([cos(theta)*sin(phi),
sin(theta)*sin(phi), cos(phi)], (theta, 0, 2*pi), (phi, 0, pi),
region_function=lambda theta, phi: phi<math.pi/2, plot_points=(100,100))
sage: show(p)
sage: p.clip_region(lambda theta,phi: theta<math.pi/2)
sage: show(p)
sage: p.clip_region(lambda x,y,z: z<0.5)
sage: show(p)
A region of a function::
sage: var('x,y')
(x,y)
sage: plot3d(sin(x)*cos(y),(x,-3,3),(y,-3,3),
region_function=lambda x,y: x<y^2, plot_points=(100,100))
sage: plot3d(sin(x)*cos(y),(x,-3,3),(y,-3,3),
region_function=lambda x,y,z: z<0 and not x>y, plot_points=(100,100))
sage: plot3d(sin(x)*cos(y),(x,-3,3),(y,-3,3),
region_function=lambda x,y: x^2+y^2<1 or x^2+y^2>4 ,
plot_points=(100,100))
sage: plot3d(sin(x)*cos(y),(x,-3,3),(y,-3,3),
region_function=lambda x,y: x^2+y^2>1 and x^2+y^2<4 ,
plot_points=(100,100))
A region of the xy plane::
sage: var('x,y')
sage: plot3d(1, (x,-3,3), (y,-3,3), region_function=lambda x,y:
x^2+y^2<7 and x<y, plot_points=(100,100))
sage: plot3d(1, (x,-3,3), (y,-3,3), region_function=lambda x,y:
x^2+y^2<7 and x<y, adaptive=True, initial_depth=7)
}}}
Also, with some glue code written, this should be possible
{{{
a=sphere()
a.clip_region(lambda x,y,z:z<0)
show(a)
}}}
THIS PATCH IS NOT READY YET.
Here are some things that still need to be done:
* Several functions need doctests (like the indexed face set clip_region)
* I had to comment out _clean_point_list() in line ~300 of
parametric_surface.pyx because it destroyed the relationship between the
vertices and the u,v coordinates that generated the vertex. We really
ought to maintain that information separately for a parametric surface,
and then update it. Once we have a way of retrieving that information
(i.e, for a vertex, give me the u and v that generated the vertex), we can
enable _clean_point_list(). This should probably be done before this
patch is merged.
--
Ticket URL: <http://trac.sagemath.org/sage_trac/ticket/5514#comment:7>
Sage <http://sagemath.org/>
Sage - Open Source Mathematical Software: Building the Car Instead of
Reinventing the Wheel
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"sage-trac" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/sage-trac?hl=en
-~----------~----~----~----~------~----~------~--~---