![]() |
Матрица статей Список статей Всячина Контакты | ||||||||||||
|
Обезьянье дерево
program MonkeysTree;
uses CRT, Graph;
var
gd, gm: Integer;
procedure Draw(x, y, l, u : Real; t, q,s : Integer);
procedure Draw2(Var x, y: Real; l, u : Real; t, q, s : Integer);
begin
Draw(x, y, l, u, t, q, s);
x := x + l*cos(u);
y := y - l*sin(u);
end;
begin
if t > 0 then
begin
if q = 1 then
begin
x := x + l*cos(u);
y := y - l*sin(u);
s := -s;
u := u + pi
end
else if q = 3 then
begin
x := x + l*cos(u);
y := y - l*sin(u);
s := s;
u := u + pi
end
else if q = 2 then
begin
s:=-s
end
else if q = 0 then
begin
s := s
end;
l := l/3;
Draw2(x, y, l, u+s*pi/3, t-1, 2,s);
Draw2(x, y, l, u+s*pi/3, t-1, 1,s);
Draw2(x, y, l, u, t-1, 0,s);
Draw2(x, y, l, u-s*pi/3, t-1, 1,s);
Draw2(x, y, l*sqrt(3)/3, u-s*7*pi/6, t-1, 1,s);
Draw2(x, y, l*sqrt(3)/3, u-s*7*pi/6, t-1, 2,s);
Draw2(x, y, l*sqrt(3)/3, u-s*5*pi/6, t-1, 3,s);
Draw2(x, y, l*sqrt(3)/3, u-s*pi/2, t-1, 3,s);
Draw2(x, y, l*sqrt(3)/3, u-s*pi/2, t-1, 0,s);
Draw2(x, y, l, u, t-1, 3,s);
Draw2(x, y, l, u, t-1, 0,s);
end
else
Line(Round(x), Round(y), Round(x + cos(u)*l), Round(y - sin(u)*l));
end;
begin
gd := Detect;
InitGraph(gd, gm, 'c:\bp\bgi');
Draw(50, 365, 430, 0, 3, 0, 1);
ReadKey; {^}
CloseGraph
end.
Следующая картинка взята из книги Б. Мандельброта Фрактальная геометрия природы.
Смотрите также: |