Le tangram-oeuf
Posté : dim. 14 oct. 2012, 15:10
Une variante du code de OG (ce n'est pas le même oeuf !)
Ce code, sûrement pas parfait, doit être plus facilement recyclable puisque les dix pièces sont définies individuellement. Il y a aussi quelques commentaires dans le code.
Je compte m'en servir pour donner un modèle de figure à obtenir en sixième. Si j'y parviens, je posterai à la suite.
Ce code, sûrement pas parfait, doit être plus facilement recyclable puisque les dix pièces sont définies individuellement. Il y a aussi quelques commentaires dans le code.
Je compte m'en servir pour donner un modèle de figure à obtenir en sixième. Si j'y parviens, je posterai à la suite.
*** Pour masquer/découvrir le code Asymptote qui a permis de créer la figure, il faut cliquer dessus. ;-) ***
- CODE ASYMPTOTE de la figure ci-dessus : Tout sélectionner
- import geometry;
- unitsize(2mm);
- // Définition des sommets, segments et arcs
- point pO=origin;
- circle cc1=circle(pO,10);
- point pA=angpoint(cc1,0), pB=rotate(180,pO)*pA, pC=rotate(90,pO)*pA, pD=rotate(180,pO)*pC;
- arc a1=arc(cc1,pB,pA);
- circle c1=circle(pA,length(pB-pA)), c2=circle(pB,length(pB-pA));
- point pF=intersectionpoints(c1,line(pA,false,pC))[0], pG=intersectionpoints(c2,line(pB,false,pC))[0];
- arc a2=arc(c1,pF,pB), a3=arc(c2,pA,pG);
- circle cc2=circle(pC,length(pF-pC));
- arc a4=arc(cc2,pG,pF);
- circle cc3=circle(pD,length(pF-pC));
- point pE=intersectionpoints(cc3,line(pC,false,pD,false))[0], pI=intersectionpoints(a4,line(pO,false,pC))[0];
- circle c3=circle(pE,length(pD-pE));
- point pH=intersectionpoints(c3,line(pA,false,pB,false))[0], pK=intersectionpoints(c3,line(pA,false,pB,false))[1];
- // Définition des pièces comme chemins fermés
- //
- // t triangle
- // tc triangle curviligne
- // qc quadrilatère curviligne
- path t1=pO--pA--pC--cycle, t2=pO--pC--pB--cycle, t3=pO--pE--pK--cycle, t4=pO--pH--pE--cycle,
- tc1=pC--pA--a3--pG--cycle, tc2=pC--pG--arc(cc2,pG,pI)--pI--cycle,
- tc3=pC--pI--arc(cc2,pI,pF)--pF--cycle, tc4=pC--pF--a2--pB--cycle,
- qc1=pH--pB--arc(cc1,pB,pD)--pD--pE--cycle, qc2=pE--pD--arc(cc1,pD,pA)--pA--pK--cycle;
- // Tracé et coloriage des dix pièces
- filldraw(t1,lightgreen,black);
- filldraw(t2,lightred,black);
- filldraw(t3,fuchsia+white,black);
- filldraw(t4,mediumgray,black);
- filldraw(tc1,lightblue,black);
- filldraw(tc2,orange+white,black);
- filldraw(tc3,lightcyan,black);
- filldraw(tc4,lightyellow,black);
- filldraw(qc1,lightolive,black);
- filldraw(qc2,0.5*cyan,black);
- // // Tracé des traits de construction
- draw(cc1,dotted);
- draw(line(pA,false,pC),dotted);
- draw(line(pB,false,pC),dotted);
- draw(cc2,dotted);
- draw(cc3,dotted);
- draw(c3,dotted);
- // // Tracé des dix pièces par arcs et segments
- draw(a1);
- draw(line(pA,false,pB,false));
- draw(line(pO,false,pI,false));
- draw(line(pA,false,pF,false));
- draw(line(pB,false,pG,false));
- draw(a2);
- draw(a3);
- draw(a4);
- draw(line(pO,false,pD,false));
- draw(line(pE,false,pH,false));
- draw(line(pE,false,pK,false));
- // Noms des sommets des pièces
- label("$O$",pO,NE);
- label("$A$",pA,align=unit(pA-pO));
- label("$B$",pB,align=unit(pB-pO));
- label("$C$",pC,E);
- label("$D$",pD,align=unit(pD-pO));
- label("$E$",pE,SE);
- label("$F$",pF,align=unit(pF-pC));
- label("$G$",pG,align=unit(pG-pC));
- label("$H$",pH,align=unit(pH-pE));
- label("$K$",pK,align=unit(pK-pE));
- label("$I$",pI,align=unit(pI-pO));