prologues:=2;
input constantes;
input geometriepoint;
%papier millimétré
vardef millimetre suffix co =
 color coul;
 numeric hauteur, largeur ;
 path p[];
 %ligne horizontale
 p1:=(x.so*cm, 0)--(x.ne*cm, 0);
 %ligne verticale
 p2:=(0,y.so*cm)--(0,y.ne*cm);
 %choix de la couleur
 if str co ="" :
 coul:= orange
 else :
 coul:=co
 fi;
 %grille centimétrique
 pickup pencircle scaled 0.5;%christ 0.7
 %lignes horizontales
 for i:=y.so step 1 until y.ne:
 draw p1 shifted (0,i*cm) withcolor coul;
 endfor;
 %lignes verticales
 for i:=x.so step 1 until x.ne :
 draw p2 shifted (i*cm,0) withcolor coul;
 endfor;
 %grille penta-centimétrique
 %lignes horizontales
%christ pickup pencircle scaled 0.5;%christ 1
%christ for i:=0 step -5 until y.so :
%christ draw p1 shifted (0,i*cm) withcolor coul;
%christ endfor;
%christ for i:=0 step 5 until y.ne :
%christ draw p1 shifted (0,i*cm) withcolor coul;
%christ endfor;
 %lignesverticales
%christ for i:=0 step -5 until x.so :
%christ draw p2 shifted (i*cm,0) withcolor coul;
%christ endfor;
%christ for i:=0 step 5 until x.ne :
%christ draw p2 shifted (i*cm,0) withcolor coul;
%christ endfor;
enddef;

vardef origine(expr p)=
  x.origine:=xpart(p);
  y.origine:=ypart(p);
enddef;

vardef papiermillimetre(expr m,n,p,q,r)suffix col=
  origine(m);
  x.u:=n*cm;
  y.u:=p*cm;
  z.so=q;
  z.ne=r;
  millimetre col;
enddef;
beginfig(0);
  affixe.A(u*(1,1))so;
  affixe.B(u*(7,1))se;
  affixe.D(u*(6.5,5))ne;
  affixe.E(u*(2.5,5))no;
  affixe.C((z.A--z.D) intersectionpoint (z.B--z.E))e;
  draw z.A--z.B--z.E--z.D--cycle;
endfig;
beginfig(1);
  affixe.O(u*(5,5))so;
  path cer;
  cer=cercle(O,3cm);
  draw cer;
  affixe.A(point(0.95*length cer) of cer)se;
  affixe.B(z.A rotatedabout(z.O,50))ne;
  affixe.C(z.B rotatedabout(z.O,150))o;
  draw triangle(B,O,C);
  draw z.O--z.A--z.C;
  draw z.A--z.B;
endfig;
beginfig(2);
  papiermillimetre((0,0),1,1,(0,0),(18,18))bleu;
  affixed.A(u*(3,13))o;
  affixed.B(z.A shifted (u*(2,4)))ne;
  drawarrow z.A--z.B;
  affixed.O(u*(8,9))no;
  affixed.E(u*(7,6))se;
  affixed.F(u*(12,11))no;
  draw droite(E,F,2);
  drawarrow (u*(2,12))..(u*(1.3,11))..(u*(1,10)) withpen pencircle scaled 2bp;
  draw (u*(3,7))--(u*(4,8))--(u*(6,8))--(u*(7,9))--(u*(6,10))--(u*(5,10))--(u*(4,9))--(u*(3,10))--cycle withpen pencircle scaled 2bp;
  label.lrt(btex $\cal P$ etex,(u*(5,9)));
endfig;
beginfig(3);
  affixe.D(u*(1,1))so;
  affixe.C(u*(7,1))se;
  affixe.B(u*(7,5))ne;
  affixe.A(u*(1,5))no;
  draw z.A--z.B--z.C--z.D--cycle;
  affixe.N(u*(5,1))s;
  affixe.M(u*(7,3))e;
  draw z.N--z.A--z.M;
  draw codesegments(B,M,N,C,2);
endfig;
beginfig(4);
  affixe.D(u*(1,1))so;
  affixe.C(u*(7,1))se;
  affixe.B(u*(7,5))ne;
  affixe.A(u*(1,5))no;
  draw z.A--z.B--z.C--z.D--cycle;
  affixe.N(u*(6,1))s;
  affixe.M(u*(7,4))e;
  draw z.N--z.A--z.M;
  draw codesegments(B,M,N,C,2);
endfig;
 
end


