Fichiers de Jean-Louis Garcin

Illusion d'optique à base d'ellipses

ellipses.mp
 
 
 
ellipses (figure 1)
beginfig(1); 
 
 path pcg, gcg, pcd,gcd,inter, trait;
 numeric u,d, i,j;
 pair A, B,C;
 
%%%%% 
 
 d=24; % prendre une valeur paire.
 u=0.3cm;
 picture pic;
 
 
 %%%%
 for i= 0 upto (d-1):
 
    pcg:=halfcircle scaled ((2*i)*u);
   gcg:= halfcircle scaled ((2*i+2)*u);
 
      for  j= (d-i) upto (d+i-1):
 
      pcd:=halfcircle scaled ((2*j)*u) shifted (d*u,0);
      gcd:=halfcircle scaled ((2*(j+1))*u) shifted (d*u,0);
 
       if (i+j)/2 =floor((i+j)/2):
        inter:= buildcycle(gcg,gcd,pcg,pcd);
         fill inter withcolor  ((i+j)/(3*d))[blue,white];
        fi
     endfor;
  endfor;
 
  for i=0 upto (d-2):
     pcg:=halfcircle scaled ((2*i)*u);
     gcg:= halfcircle scaled ((2*i+2)*u);
     j:=d+i;
      pcd:=halfcircle scaled ((2*j)*u) shifted (d*u,0);
     gcd:=halfcircle scaled ((2*(j+1))*u) shifted (d*u,0);
     trait:=((-i)*u,0)--((-(i+1))*u,0);
     inter:= buildcycle(gcg,gcd,trait,pcd); 
     fill inter withcolor  ((2*i+d)/(3*d))[blue,white];
    draw trait withcolor  ((2*i+d)/(3*d))[blue,white];
  endfor;
 
  pic:=currentpicture;
  draw pic yscaled -1;
  pic:=currentpicture;
 
  draw pic rotatedaround (((d/2)*u,0),180); 
 
  endfig; 
 end; 
 

Intersection de paraboles

paraboles.mp
%@AUTEUR: Jean-Louis Garcin
%@DATE: 26 juin 2010
 
paraboles (figure 1)
beginfig(1); 
 
 path pc,gc, traitb,traith,inter,trait,traitv;
 numeric u,d, r,h;
 picture pic;
 %%%%% 
 
 d=35;
 u=0.3cm;
 
 %%%%
 for r= 0 upto (d-1):
   pc := halfcircle scaled ((2*r)*u) rotated (-90);
   gc := halfcircle scaled ((2*r+2)*u) rotated (-90);
 
   for  h= 0 upto (r-1):
     traitb := (0,h*u)-- (d*u,h*u);
     traith := (0,(h+1)*u)--(d*u,(h+1)*u);
     if  ((r+h)/2) >floor((r+h)/2):
       inter:= buildcycle(traitb,pc,traith,gc);
       draw inter withcolor  ((r+h)/(2.2*d))[black,white];
       fill inter withcolor  ((r+h)/(2.2*d))[black,white];
     fi
   endfor;
 endfor;
 
 for r = (-3) downto (- d):
   pc := halfcircle scaled (2*(abs(r+1))*u)   rotated (-90);
   gc :=  halfcircle scaled (2*(abs(r))*u   )   rotated (-90);
   for  h= -1 downto  r+1 :
     traitb := (0,h*u)-- (d*u,h*u);
     traith := (0,(h+1)*u)--(d*u,(h+1)*u);
     if  ((r+h)/2) =floor((r+h)/2):
       inter:= buildcycle(traitb,gc,traith,pc);
       draw inter withcolor ((-r-h)/(2.2*d))[black,white];
       fill inter withcolor  ((-r-h)/(2.2*d))[black,white];
     fi
   endfor;
 endfor;
 
 for r=  1 upto d:
   gc :=  halfcircle scaled (2*r*u)   rotated (-90);
   trait:= (0,(1-r)*u)-- (d*u,(1-r)*u);
   traitv:=(0,(1-r)*u)--(0,-(r*u));
   inter:=buildcycle(traitv,trait,gc);
   fill inter withcolor  ((2*r)/(2.2*d))[black,white];
   draw inter withcolor  ((2*r)/(2.2*d))[black,white];
 endfor;
 
 pic:=currentpicture;
 
 draw pic xscaled (-1);
endfig;
end;