wxMaxima

Animations

How to create animations

Simple animations with one parameter can be viewed inside wxMaxima and animated using the slider in the toolbar.

There are several functions for creating animations:

The first two parameters to with_slider* functions are the parameter name and a list of parameter values. The remaining parameters describe the frame and should be valid input for function which will be used to create the frames. For with_slider and with_slider3d functions the parameter can appear only in the first of the remaining arguments and for with_slider_draw and with_slider_draw3d the parameter can appear in all remaining arguments.

To move between frames in the animation, first select the animation with the mouse and then move between frames using the slider in the toolbar.

Screencasts:

Examples

The first example creates an animation using the plot2d function.

tay(n, x) := block(
   [ts : taylor(sin(x__), x__, 0, n)],
   subst(x__=x, ts)
)$
with_slider(
   /* first two arguments are the parameter and parameter values */
   n, 2*range(1, 10)-1,
   /* the rest of arguments are for plot2d command */
   [sin(x), '(tay(n, x))],
   [x, -9, 9],
   [y, -2, 2]
)$

The rest of examples create animations using the draw2d function. For these examples the draw package must be loaded before executing them.

with_slider_draw(
   /* first two arguments are the parameter and parameter values */
   a, makelist(i, i, 0, 30)/5,
   /* the rest of arguments describe a draw2d scene */
   fill_color = green,
   color = black,
       polygon([[0,0], [6,0], [6,8]]),
   fill_color = red,
       polygon([[a, 0], [6,0], [6, 4*a/3], [a,4*a/3]]),
   color = black,
   line_width = 3,
   key = "Area of inscribed rectangle",
       explicit(4*x/3*(6-x), x, 0, a),
   yrange = [0, 14],
   xrange = [-2, 8]
)$
with_slider_draw(
   /* first two arguments are the parameter and parameter values */ 
   a, makelist(i, i, 0, 20)*%pi/10,
   /* the rest of arguments describe a draw2d scene */
       parametric(-1+cos(t), sin(t), t, 0, 2*%pi),
   line_width = 2,
   color = blue,
       explicit(sin(x), x, 0, a),
   color = green,
   points_joined = true,
   point_size = 0,
   line_width = 1,
       points([[-1,0], [-1+cos(a), sin(a)]]),
   color = black,
       explicit(sin(a), x, -1+cos(a), a),
   pic_width = 600,
   pic_height = 400,
   yrange = [-2, 2],
   xrange = [-3, 2*%pi+1],
   xaxis = true,
   yaxis = true
)$

The last example is taken from [1].

with_slider_draw(
   /* first two arguments are the parameter and parameter values */
   ang, makelist(i,i,0,20)*%pi/10,
   /* the rest of arguments describe a draw2d scene */
   pic_width = 600,
   pic_height = 400,
   xrange     = [-10,10],
   yrange     = [-11,10],
   nticks     = 80,
   color      = red,
      parametric(6*cos(u),
                 6*sin(u),
                 u,0,2*%pi),
      parametric((6+2)*sin(ang)+2*cos(u),
                 (6+2)*cos(ang)+2*sin(u),
                 u,0,2*%pi),
   color = blue,
   line_width = 2,
      parametric((6+2)*sin(a)-2*sin(a*(1+6/2)),
                 (6+2)*cos(a)-2*cos(a*(1+6/2)),
                 a,0,ang),
   color      = black,
   point_size = 1,
   points_joined = true,
   line_width = 1,
      points([
              [0,0],
              (6+2)*[sin(ang),cos(ang)],
              [(6+2)*sin(ang)-2*sin(ang*(1+6/2)),
               (6+2)*cos(ang)-2*cos(ang*(1+6/2))]
             ]))$
MediaWiki Sourceforge.net Logo
© 2006-2007 Andrej Vodopivec