#2646: create plot_vector_field3d function
-------------------------+--------------------------------------------------
Reporter: jason | Owner: was
Type: enhancement | Status: new
Priority: major | Milestone: sage-4.0
Component: graphics | Keywords:
-------------------------+--------------------------------------------------
Comment(by jason):
Here's another version that offers the option of centering the arrows on
the point.
{{{
def plot_vector_field3d(vec, xrange, yrange, zrange, plot_points=[5,5,5],
center_arrows=False,**kwds):
xvar, xmin, xmax = xrange
yvar, ymin, ymax = yrange
zvar, zmin, zmax = zrange
if not isinstance(plot_points, (list, tuple)):
plot_points = [plot_points]*3
ff, gg, hh = fast_float(vec, xvar, yvar, zvar)
xpoints = [xmin..xmax, step=float(xmax-
xmin)/(plot_points[0]-1)][0:plot_points[0]]
ypoints = [ymin..ymax, step=float(ymax-
ymin)/(plot_points[1]-1)][0:plot_points[1]]
zpoints = [zmin..zmax, step=float(zmax-
zmin)/(plot_points[2]-1)][0:plot_points[2]]
points = [vector((i,j,k)) for i in xpoints for j in ypoints for k in
zpoints]
vectors = [vector((ff(*point), gg(*point), hh(*point))) for point in
points]
# scale the vectors
max_len = max(v.norm() for v in vectors)
scaled_vectors = [v/max_len for v in vectors]
if center_arrows:
return sum([plot(v,**kwds).translate(p-v/2) for v,p in
zip(scaled_vectors, points)])
else:
return sum([plot(v,**kwds).translate(p) for v,p in
zip(scaled_vectors, points)])
}}}
I think the only other thing that the function in the worksheet linked
above does is provide an option to make the arrows thicker (based on the
scaling, I believe).
--
Ticket URL: <http://trac.sagemath.org/sage_trac/ticket/2646#comment:4>
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
-~----------~----~----~----~------~----~------~--~---