summaryrefslogtreecommitdiff
path: root/info/examples/lgc2/D-4-1.mp
blob: 6e30094c1a5972fc9c3e64ded727b955e11ec514 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
% --- start of displayed preamble in the book ---

% --- end of displayed preamble in the book ---
defaultfont:="ptmr8r";
warningcheck:=0;
beginfig(1)
% Déclaration de mes pictures qui permettront la composition de l'image
picture rond,rondn,rondb;

numeric diamax;

u:=1.5mm;

% Fabrication de l'image de base

rond = image(
    for i:=15 downto 0:
        % cercle permettant de faire la "bande circulaire"
        path cercle, cercleb;
        numeric r,rb,moy,diff;
        % le rayon du plus petit cercle
        r:=6*2.71**((i/10))*0.3*u;
        % celui du plus grand
        rb:=6*2.71**((i+1)/10)*0.3*u;
        % On sauvegarde le diamètre maximal de la figure
        if i=15:
            diamax:=rb;
        fi;
        % rayon du cercle "médiant"
        moy:=(r+rb)/4;
        % laRgeur de la bande circulaire
        diff:=rb-r;
        cercle := fullcircle scaled (r);
        cercleb := fullcircle scaled (rb);
        % astuce permettant de palier au problèmes engendrés
        % par "buildcycle" qui trace dans la suite un disque noir,
        % ceci permet aussi de ne pas avoir de transparant
        fill cercleb withcolor white;
        for j:=0 step 2 until 36:
            pair P,P',O;
            path noir,dr,drb,p,c,d,e,f;
            O:=(0,0);
            % Le point où l'on fixe la première ellipse
            P:=(moy)*(cosd(j*10+i*10),sind(j*10+10*i));
            % Le point ou l'on fixe la deuxième ellipse
            P':=(moy)*(cosd(10*i+(j+1)*10),sind(10*i+(j+1)*10));
            dr:=O--(2*xpart P,  2*ypart P);
            drb:=O--(2*xpart P',  2*ypart P');
            % Partie noire de la bande
            p = buildcycle(cercle,dr,cercleb,drb);
            fill p;
            % tracé des ellipses
            fill fullcircle xscaled (diff/4) yscaled (diff/2)
                rotated(90+10*j+10*i) shifted P withcolor green ;
            fill fullcircle xscaled (diff/4) yscaled (diff/2)
                rotated(90+10*(j+1)+10*i) shifted P' withcolor red ;
        endfor;
    endfor;
);

    %Déclaration de la transformation de symétrie
    transform T;
    T = identity reflectedabout((diamax/2,-20),(diamax/2,20));
    % la picture symétrique
    rondn = rond transformed T;
    % remise à  l'origine
    rondb=rondn shifted (-diamax,0);
    for i:=0 upto 1:
        for j:=0 upto 1:
            if (j mod 2)=0:
                draw rondb rotated(i*10)
                    shifted  (j*diamax,i*diamax) ;
            else:
                draw rond rotated(i*10)
                    shifted  (j*diamax,i*diamax) ;
            fi;
        endfor;
    endfor;
    for i:= 0 upto 0:
        for j:=0 upto 0:
            if j=1:
                draw rondb rotated(i*10)
                    shifted  (j*diamax+diamax/2,i*diamax+diamax/2) ;
            else:
                draw rond rotated(i*10)
                    shifted  (j*diamax+diamax/2,i*diamax+diamax/2) ;
            fi;
        endfor;
    endfor;
endfig;
end;