#### 6.38 animating a zoom process (21.9.99)

##### 6.38.1 Richard Pulskamp

We cannot achieve a desired eﬀect in an animation. Does anyone have a workaround? We are running Release 5.1. An example of the code used follows.

The particular diﬃculties are described later.

Here is an animation we want to use in Calculus I to mimic repeated zooming in on the graph of a function together with its tangent line:

 f:=x->x^3+2*x-1:
with(plots):
A:=array(1..8):
for i from 1 to 8 do
plot1[i]:=plot(f(x),x=1-.5^i..1+.5^i,axes=box,color=red):
plot2[i]:=plot(5*x-3,x=1-.5^i..1+.5^i,axes=box,color=blue):
plot3[i]:=pointplot([[1,2]],style=point,symbol=circle):
A[i]:=display([plot1[i],plot2[i],plot3[i]]):
od:
display([seq(A[k],k=1..8)],insequence=true);



The above animation does show the frames which create the "zooming- in-eﬀect" we want, but we do not get the desired eﬀect because Maple does not enlarge the individual frames. In other words, it would appear that the graph dimensions cannot be dynamically resized.

DIFFICULTY I :We would like to produce an animation of the following pictures (exactly as shown) in an animation where the scale on the axes changes (i.e. new scales on both axes from frame to frame).

> display(%);



The Plot[Structure] option "FRAMESCALING" seems to have been designed to do this job. Experimentation with this option showed that this option is not functioning properly, as the following example should demonstrates:

 for i from 1 to 5 do
plot1[i]:=plot(sin(x),x=0..i*Pi,axes=box):
od:
display(seq(plot1[i],i=1..5),insequence=true,framescaling=nonuniform);



DIFFICULTY 2: Since we would like to post these animations for our students, we want to preset the frame-rate, i.e. the number of FRAMES PER SECOND in the animation command rather than this having to be done by the viewer. How can this be done?

This does not seem to be an option.

##### 6.38.2 Rexford Cordill (29.10.99)

Zooming in on a 2D or 3D plot in MapleV is a feature that should be well documented, but to my knowledge it isn’t. I found a very good solution in the DEtools[zoom] command. The MapleV help page on DEtools[zoom] is very good and you shouldn’t have any trouble implementing it. Just implement this command in your ’for’ loop followed by

plots[display]([seq(plot1[j],j=1..5)],insequence=true);



You can fake varying the frame rate by merely duplicating plot structures in the list of plot structures passed to plots[display]. For example:

plots[display]([plot1[1],plot1[2],plot1[3],plot1[4]],insequence=true);



You could write

plots[display]([plot1[1],plot1[1],plot1[2],plot1[2],plot1[3],plot1[3],plot1[4],plot1[4]],
insequence=true);



Duplicating the plots in the list would appear to halve the frame rate. Note that this basic technique could be used to display part of the animation at a diﬀerent rate than other parts.

##### 6.38.3 Bernd Rossa (29.10.99)

A few days ago you were kind to respond to a message which my colleague Dick Pulskamp had forwarded to MUG concerning the animation of a zooming process in Maple V release 5.1.

You pointed out that DEtools contains the zoom-command, which is, of course, true. This command seems to have been designed for enlarging a segment of a plot structure without having Maple recalculate the structure (from scratch).

This command speeds up the process of seeting up the frames needed to produce the desired "zooming movie".

However, as before (when I constructed the frames without the zoom command) my problem occurs when I want to display the frames "insequence=true".

In the animation, Maple refuses to adjust the scale on the window! Instead, the portion of the graph shrinks inside of the largest (ﬁrst) window, rather than the scales on the window changing which would create the desired zooming (i.e. cranking up a microscope) eﬀect.

Please look at the following example (which uses "zoom"):

> with(plots):with(DEtools):



Deﬁne a function:

> f:=x->x^3+2*x-1:



Deﬁne a plot-structure to zoom in on:

> A:=plot(f(x),x=0.5..1.5,y=0..5,axes=box,color=red):
> display(A);



Deﬁne the frames which zoom in on (1,2):

> for i from 1 to 8 do
> plot1[i]:=zoom(A,1=1-.5^i..1+0.5^i,2=2-5*.5^i..2+5*.5^i):
> od:



Finally display the frames "insequence=true":

> display([A,seq(plot1[i],i=1..8)],insequence=true);



Notice that the portion of the graph shrinks. No zooming eﬀect! But if you look at each frame separately, the zooming occurred. Maple does not change the scale on the individual windows. That’s my problem. Any further ideas? (Am I being stupid?) :-).

##### 6.38.4 Robert Israel (3.11.99)
| DIFFICULTY I :We would like to produce an animation ...



You might try something like this:

> with(plots): with(plottools):
> maketicks:= proc(a,b,s,c)
# get list of tickmarks for plot scaled by scale factor s
# about centre c, with unscaled bounds a .. b
local xt, r,j;
r:= b-a;
xt:= 10^ilog10(r);
if r < 1.5*xt then xt:= xt/5
elif r < 4*xt then xt:= xt/2
fi;
[seq(c+j*s*xt = c+j*xt, j = floor((a-c)/xt) .. ceil((b-c)/xt))];
end;

> for i from 1 to 30 do
p1:= scale(plot(f(x),x= 1 - 1.1^(-i) .. 1 + 1.1^(-i), axes=box,
colour=red), 1.1^(i-1), 1.1^(i-1),[1,2]):
p2[i]:= display(p1, labels=[x,y],
xtickmarks = maketicks(1-1.1^(-i),1+1.1^(-i),1.1^(i-1),1),
ytickmarks = maketicks(2-6*1.1^(-i),2+6*1.1^(-i),1.1^(i-1),2));
od:
> display([seq(p2[i],i=1..30)],insequence=true);