input geometriesyr16;

vardef carreext(expr aa,bb,typehach,typeecrit,ecrit)=
  save $;
  picture $;
  $=image(
    if typehach=1:
      trace hachurage(polygone(aa,rotation(bb,aa,-90),rotation(aa,bb,90),bb),60,0.2,0);
    elseif typehach=2:
      trace hachurage(polygone(aa,rotation(bb,aa,-90),rotation(aa,bb,90),bb),150,0.2,0);
    elseif typehach=3:
      trace hachurage(polygone(aa,rotation(bb,aa,-90),rotation(aa,bb,90),bb),60,0.2,0);
      trace hachurage(polygone(aa,rotation(bb,aa,-90),rotation(aa,bb,90),bb),150,0.2,0);
    fi;
    trace chemin(aa,rotation(bb,aa,-90),rotation(aa,bb,90),bb);
    remplis cercles(iso(aa,rotation(bb,aa,-90),rotation(aa,bb,90),bb),(sqrt(2)/4)*abs(aa-bb)) withcolor blanc;
    trace cercles(iso(aa,rotation(bb,aa,-90),rotation(aa,bb,90),bb),(sqrt(2)/4)*abs(aa-bb));
    if typeecrit=0:
      label(btex \dots etex,iso(aa,rotation(bb,aa,-90),rotation(aa,bb,90),bb));
      label(btex \dots etex,1.25[iso(aa,bb),symetrie(iso(aa,bb),iso(aa,rotation(bb,aa,-90),rotation(aa,bb,90),bb))]);
    elseif typeecrit=1:
      label(btex \dots etex,iso(aa,rotation(bb,aa,-90),rotation(aa,bb,90),bb));
      label(ecrit,1.25[iso(aa,bb),symetrie(iso(aa,bb),iso(aa,rotation(bb,aa,-90),rotation(aa,bb,90),bb))]);
    elseif typeecrit=2:
      label(ecrit,iso(aa,rotation(bb,aa,-90),rotation(aa,bb,90),bb));
      label(btex \dots etex,1.25[iso(aa,bb),symetrie(iso(aa,bb),iso(aa,rotation(bb,aa,-90),rotation(aa,bb,90),bb))]);
    fi;
    );
  $
enddef;

figure(-3u,-3u,5u,8u);
u:=6mm;
pair A,B,C;
A=u*(1,1);
B-A=u*(3,0);
C-A=u*(0,2);
trace polygone(A,B,C);
trace codeperp(C,A,B,5);
trace carreext(A,B,1,1,btex 6 etex);
trace carreext(B,C,3,0,btex etex);
trace carreext(C,A,2,1,btex 4 etex);
fin;
u:=1cm;
figure(-3u,-3u,6u,8u);
u:=6mm;
pair A,B,C;
A=u*(1,1);
B-A=u*(3.5,0);
C=pointarc(cercledia(A,B),55);
trace polygone(A,B,C);
trace codeperp(A,C,B,5);
trace carreext(A,B,3,1,btex 10 etex);
trace carreext(B,C,1,0,btex etex);
trace carreext(C,A,2,1,btex 8 etex);
fin;
u:=1cm;
figure(-3u,-3u,7u,8u);
u:=6mm;
pair A,B,C;
A=u*(1,3);
B-A=u*(3,0);
C-A=u*(0,-2);
trace polygone(A,B,C);
trace codeperp(C,A,B,5);
trace carreext(B,A,1,1,btex 5 etex);
trace carreext(C,B,3,1,btex 8 etex);
trace carreext(A,C,2,0,btex  etex);
fin;
u:=1cm;
figure(-3u,-3u,7u,8u);
u:=6mm;
pair A,B,C;
A=u*(1,3);
B-A=u*(3,0);
C-A=u*(0,-2);
trace polygone(A,B,C);
trace codeperp(C,A,B,5);
trace carreext(B,A,1,1,btex 6 etex);
trace carreext(C,B,3,1,btex 7 etex);
trace carreext(A,C,2,0,btex  etex);
fin;
u:=1cm;
figure(-3u,-3u,5u,8u);
u:=6mm;
pair A,B,C;
A=u*(1,1);
B-A=u*(2,0);
C-A=u*(0,3);
trace polygone(A,B,C);
trace codeperp(C,A,B,5);
trace carreext(A,B,1,1,btex 5 etex);
trace carreext(B,C,3,1,btex 7 etex);
trace carreext(C,A,2,0,btex  etex);
fin;
u:=1cm;
figure(-3u,-3u,5u,8u);
u:=6mm;
pair A,B,C;
A=u*(1,1);
B-A=u*(4,0);
C=pointarc(cercledia(A,B),300);
trace polygone(A,B,C);
trace codeperp(A,C,B,5);
trace carreext(B,A,3,2,btex 81 etex);
trace carreext(C,B,2,2,btex 64 etex);
trace carreext(A,C,1,0,btex  etex);
fin;
end