function sierpins
% Sierpins (sky) Fraktalas, pagal M.F. Barnsley, L.P. Hurd,
% fractal Image Compression, A.K. Peters Ltd., 1993
% Sierpinskio fraktalas apibreziamas 18 skaiciu:
% w1: (x,y) ->(0.5*x,0.5*y),
% w2: (x,y) ->(0.5*x+0.5,0.5*y),
% w3: (x,y) ->(0.5*x,0.5*y+0.5),

N=1024*16*4;
x=zeros(1,N); y=zeros(1,N); ii=randperm(N);
w=zeros(2,2,3); b1=[0 0.5 0]; b2=[0 0 0.5]; 
w(:,:,1)=[0.5 0; 0 0.5]; 
w(:,:,2)=[0.5 0; 0 0.5]; 
w(:,:,3)=[0.5 0; 0 0.5]; 

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