Animated Projection of a Parabola



Here is how I did this in Euler Math Toolbox (EMT).

We imagine the viewpoint at x=-1.2, y=0, z=0 with the z-axis vertically and the x-y-plane horizontally. The parabola is z=y^2 with x=0. We turn the parabola and a grid on the y-z-plane away from our viewpoint, until finally the parabola becomes x=y^2  with z=0, and the grid is in the x-y-plane.

First we write two functions. The first simply turns a point (x,y,z) around the y-axis towards the x-axis. The second does the plot depending on the angle of turn alpha.

>function turn (x,y,z,alpha) ...
$  x=-cos(alpha)*x+sin(alpha)*z;
$  z=cos(alpha)*z+sin(alpha)*x;
$  return {y/(x+1.2),z/(x+1.2)}
$  endfunction
>function plotgrid (alpha) ...
$  y=-1000:1000; z=(-1:1000)'; x=0;
$  {xp,yp}=turn(x,y,z,alpha);
$  window(0,0,1024,1024);
$  setplot(-2,2,-2,2); clg;
$  hold on;
$  color(gray);
$  plot(xp,yp);
$  plot(xp',yp');
$  t=-1000:0.01:1000; s=t^2;
$  {xp,yp}=turn(0,t,s,alpha);
$  cl=color(red); lw=linewidth(2); plot(xp,yp);
$  color(cl); linewidth(lw);
$  hold off;
$  endfunction

For this we use some primitive plot functions.

To create a GIF, we use „convert“ from ImageMagic. The following function will call any other function depending on parameter and create a GIF.

>function makegif (f$,x) ...
$  count=1;
$  for t=x;
$     f$(t;args());
$     wait(0.01);
$     savepng("im"+printf("%03d",count)+".png");
$     count=count+1;
$  end;
$  exec("convert","im* animation.gif");
$  exec("cmd","/c del im*.png");
$  endfunction

Schreibe einen Kommentar

Deine E-Mail-Adresse wird nicht veröffentlicht. Erforderliche Felder sind mit * markiert.

Diese Website verwendet Akismet, um Spam zu reduzieren. Erfahre mehr darüber, wie deine Kommentardaten verarbeitet werden.