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
| {************************************************
Hugo Etiévant
http://www.multimania.com/cyberzoide/
e-mail : cyberzoide@multimania.com
(pour une aide en Turbo Pascal 7.0)
*************************************************}
(************************************************
TRACÉ D'UNE FRACTALE COMPOSÉE DE CERCLES
par un algorithme récursif
ALGO : si le rang de précision n'est pas dépassé
alors on trace un cercle principal de rayon R au
sein duquel on trace 4 autres petits cercles de
rayon r maximum c'est-à-dire tel que
r:=R/(1+Sqrt(2)). Le trac de chaque petit cercle
se fait par rappel de la procédure rcursive.
*************************************************)
program fractale;
uses graph;
procedure cercle(x,y,rayon:real; n:integer);
var a,b:real;
begin
if n>0 then
begin
circle(round(x),round(y),round(rayon)); {cercle principal}
rayon:=rayon/(1+sqrt(2)); {dcrmentation gomtrique du rayon}
dec(n); {dcrmentation du rang}
{ Pour des cercles plus petits au milieu de chaque quadruplets :
circle(round(x),round(y+rayon*sqrt(2)),round(rayon));
circle(round(x+rayon*sqrt(2)),round(y),round(rayon));
circle(round(x),round(y-rayon*sqrt(2)),round(rayon));
circle(round(x-rayon*sqrt(2)),round(y),round(rayon)); }
{trac des quatres petits cercles par appel rcursif : ...}
cercle(x,y+rayon*sqrt(2),rayon,n);
cercle(x+rayon*sqrt(2),y,rayon,n);
cercle(x,y-rayon*sqrt(2),rayon,n);
cercle(x-rayon*sqrt(2),y,rayon,n);
end;
end;
var pilote,mode,n:integer;
rayon,x,y:real;
BEGIN
{initialisation du mode graphique : ...}
pilote:=detect;
initgraph(pilote,mode,'c:\tp7\bgi');
{initialisation des valeurs initiales : ...}
rayon:=getmaxy/2; {rayon le plus grand possible}
x:=getmaxx/2; y:=getmaxy/2; {centre de l'cran graphique courant}
n:=5; {choix du nombre d'itrations}
cercle(x,y,rayon,n); {appel de la procdure rcursive de trac des cercles}
readln; {pause}
closegraph; {quitte le mode graphique}
END. |