function dragon
% dragon Fraktalas, pagal M.F. Barnsley, L.P. Hurd,
% fractal Image Compression, A.K. Peters Ltd., 1993
% Drakonas apibreziamas 12 skaiciu:
% w1: (x,y) ->(0.45*x-0.50*y,0.40*x+0.55*y),
% w2: (x,y) ->(0.45*x-0.50*y+1,0.40*x+0.55*y)

N=1024*16*4;
x=zeros(1,N); y=zeros(1,N); ii=randperm(N);
w=zeros(2,2,2); b=[0 1]; 
w(:,:,1)=[0.45  -0.50; 0.40 0.55]; 
w(:,:,2)=[0.45 -0.50;  0.40 0.55];

for k=2:N,
 i=mod(ii(k),2)+1;
 p=w(:,:,i)*[x(k-1);y(k-1)];
 x(k)=p(1)+b(i); y(k)=p(2);
end;
plot(x,y,'k.');
