#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):

 I rewrote my code above too.  Now I just plot the vector, since #5450
 makes sure that plotting a vector actually plots line3d:

 {{{
 def plot_vector_field3d(vec, xrange, yrange, zrange, plot_points=[5,5,5],
 **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]
     return sum([plot(v,**kwds).translate(p) for v,p in zip(scaled_vectors,
 points)])
 }}}

-- 
Ticket URL: <http://trac.sagemath.org/sage_trac/ticket/2646#comment:3>
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to