Код
uses graph, crt;
Type
TComplex = record
re : Real;
im : Real;
end;
type
TPoint = record
x : Integer;
y : Integer;
z : Integer;
end;
const
iteration = 25;
max = 10;
long = 100;
betw = 4;
xalpha = -1.2;
zalpha = 0.5;
yalpha = 0.2;
ndiv = 0.1;
xmov = 800;
ymov = 50;
var
a, b, c : TComplex;
x, y, n, gd, gm, maxx, maxy : Integer;
res : array [-long..long,-long..long] of TPoint;
begin
gd := Detect;
InitGraph(gd,gm,'');
maxx := GetMaxX div 2;
maxy := GetMaxY div 2;
for y := -long to long do
for x := -long to long do begin
n := 0;
a.re := x * betw * 0.0025;
a.im := y * betw * 0.0025;
c.re := 0.11;
c.im :=-0.66;
while ( a.re*a.re + a.im*a.im < max) and (n < iteration) do begin
b := a;
a.re := b.re*b.re - b.im*b.im + c.re;
a.im := 2 * b.re * b.im + c.im;
inc(n);
end;
If n < iteration then begin
res[x,y].x:=maxx + x * betw;
res[x,y].y:=round( cos(xalpha)*(maxy + y * betw)-
sin(xalpha)*(n / ndiv));
res[x,y].z:=round( sin(xalpha)*(maxy + y * betw)
+cos(xalpha)*(n / ndiv));
res[x,y].x:=round(cos(zalpha)*res[x,y].x-sin(zalpha)*res[x,y].y);
res[x,y].y:=round(sin(zalpha)*res[x,y].x+cos(zalpha)*res[x,y].y);
res[x,y].x:=-round(cos(yalpha)*res[x,y].x+sin(yalpha)*res[x,y].z);
res[x,y].y:=-round(-sin(yalpha)*res[x,y].x+cos(yalpha)*res[x,y].z);
end;
end;
for y:=-long to long do
for x:=-long to long do
putpixel(res[x,y].x+xmov,res[x,y].y+ymov,5);
readkey;
closegraph;
end.
Type
TComplex = record
re : Real;
im : Real;
end;
type
TPoint = record
x : Integer;
y : Integer;
z : Integer;
end;
const
iteration = 25;
max = 10;
long = 100;
betw = 4;
xalpha = -1.2;
zalpha = 0.5;
yalpha = 0.2;
ndiv = 0.1;
xmov = 800;
ymov = 50;
var
a, b, c : TComplex;
x, y, n, gd, gm, maxx, maxy : Integer;
res : array [-long..long,-long..long] of TPoint;
begin
gd := Detect;
InitGraph(gd,gm,'');
maxx := GetMaxX div 2;
maxy := GetMaxY div 2;
for y := -long to long do
for x := -long to long do begin
n := 0;
a.re := x * betw * 0.0025;
a.im := y * betw * 0.0025;
c.re := 0.11;
c.im :=-0.66;
while ( a.re*a.re + a.im*a.im < max) and (n < iteration) do begin
b := a;
a.re := b.re*b.re - b.im*b.im + c.re;
a.im := 2 * b.re * b.im + c.im;
inc(n);
end;
If n < iteration then begin
res[x,y].x:=maxx + x * betw;
res[x,y].y:=round( cos(xalpha)*(maxy + y * betw)-
sin(xalpha)*(n / ndiv));
res[x,y].z:=round( sin(xalpha)*(maxy + y * betw)
+cos(xalpha)*(n / ndiv));
res[x,y].x:=round(cos(zalpha)*res[x,y].x-sin(zalpha)*res[x,y].y);
res[x,y].y:=round(sin(zalpha)*res[x,y].x+cos(zalpha)*res[x,y].y);
res[x,y].x:=-round(cos(yalpha)*res[x,y].x+sin(yalpha)*res[x,y].z);
res[x,y].y:=-round(-sin(yalpha)*res[x,y].x+cos(yalpha)*res[x,y].z);
end;
end;
for y:=-long to long do
for x:=-long to long do
putpixel(res[x,y].x+xmov,res[x,y].y+ymov,5);
readkey;
closegraph;
end.
Если будут идеи, какой фрактал взять вместо этого, буду благодарен.