#12827: Expand Animation class to accept more graphics types
-------------------------------------+-------------------------------------
       Reporter:  niles              |        Owner:  jason, was
           Type:  enhancement        |       Status:  needs_review
       Priority:  major              |    Milestone:  sage-6.1
      Component:  graphics           |   Resolution:
       Keywords:  animate,           |    Merged in:
  graphics, 3D                       |    Reviewers:
        Authors:  Niles Johnson      |  Work issues:  docstrings, testing,
Report Upstream:  N/A                |  think about img protocol
         Branch:                     |       Commit:
  u/niles/ticket/12827               |  de5349040ebab566d5a0e35d99284e628ab21080
   Dependencies:                     |     Stopgaps:
-------------------------------------+-------------------------------------

Comment (by niles):

 Attached some animated gifs to show what the new patch can do.  Code is
 below.  It's also worth mentioning that this patch fixes some doctest
 errors in the `Animation.ffmpeg()` method.  These are caused by a change
 in the way `tmp_filename` works, and the way file extensions are handled
 ('.gif' v.s. 'gif') elsewhere in sage.  These bugs cause `animate` to
 break when `convert` is not available but `ffmpeg` is (e.g. on the sage
 cell servers).

 Examples that this patch makes possible:

 Animate graphics arrays show accumulation of area under a curve.
 {{{
 f(x) = 8*(x-4)^2 - 25
 F(x) = f.integrate(x)
 a,b = 0,7
 M = max((_.find_local_maximum(a,b)[0] for _ in (f,F)))
 m = min((_.find_local_minimum(a,b)[0] for _ in (f,F)))
 bounding_pts = point([(a,0),(b,0),(0,m),(0,M)],color='black')

 def fplot(t):
     return plot(f,a,a + t*(b-a),fill=True) + plot(f,a,b) + \
         line([(a + t*(b-a),0),(a + t*(b-a),f(a + t*(b-a)))],thickness=2) +
 bounding_pts

 def Fplot(t):
     return plot(F,a,a + t*(b-a),color='green') + \
         point((a + t*(b-a),F(a + t*(b-a))),color='green',size=15) +
 bounding_pts

 accumulation = animate((graphics_array([fplot(t),Fplot(t)]) for t in
 sxrange(.01,1,.05)))
 accumulation.show()
 }}}

 Animate parametric surfaces and curves to draw a torus knot.
 {{{
 var('u,v');
 a,b = 2,1 # outer and inner radii
 x = (a + b*cos(u))*cos(v)
 y = (a + b*cos(u))*sin(v)
 z = b*sin(u)
 T = parametric_plot3d([x,y,z], (u,0,2*pi),(v,0,2*pi),
 opacity=.6,aspect_ratio=1)

 var('t');
 c = (2*t,3*t)
 s = [_.subs(dict(zip((u,v),c))) for _ in (x,y,z)]
 curve = lambda d:
 parametric_plot(s,(t,0,2*pi*d),color='red',thickness=2,plot_points=400)

 K = animate((T+curve(d) for d in sxrange(.01,1.1,.05)))
 K.show()
 }}}

 Animate Tachyon scenes to show the twisted cubic.
 {{{
 def tw_cubic(t):
     q = Tachyon(camera_center=(-2,3,1),xres=500,yres=500)
     q.light((1,1,11), 1,(1,0,1))
     q.light((1,5,1), .5,(0,1,1))
     q.texture('mirror', ambient=0.05, diffuse=0.05, specular=.9,
 opacity=0.9, color=(.8,.8,.8))
     q.texture('w',color=(1,1,1))
     q.plane((0,0,-2),(0,0,1),'w')
     q.plane((0,-2,0),(0,1,0),'w')
     for i in srange(-1,t,0.05):
         q.sphere((i,i^2-0.5,i^3), 0.1, 'mirror')
     return q

 W = animate([tw_cubic(t) for t in srange(-1,1.5,.1)])
 W.show()
 }}}

--
Ticket URL: <http://trac.sagemath.org/ticket/12827#comment:18>
Sage <http://www.sagemath.org>
Sage: Creating a Viable Open Source Alternative to Magma, Maple, Mathematica, 
and MATLAB

-- 
You received this message because you are subscribed to the Google Groups 
"sage-trac" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/sage-trac.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to