function hilbertc
% hilbertc Hilberto kreive, pagal M.F. Barnsley, L.P. Hurd,
% fractal Image Compression, A.K. Peters Ltd., 1993

N=256; N8=N/8;
x=zeros(1,N); y=zeros(1,N);
ii=1:N8; t=(ii-1)/N8;
x(ii)=t/4; y(ii)=1/4;
ii=ii+N8; x(ii)=1/4; y(ii)=t/4+1/4;
ii=ii+N8; x(ii)=1/4; y(ii)=t/4+1/2;
ii=ii+N8; x(ii)=t/4+1/4; y(ii)=3/4;
ii=ii+N8; x(ii)=t/4+1/2; y(ii)=3/4;
ii=ii+N8; x(ii)=3/4; y(ii)=-t/4+3/4;
ii=ii+N8; x(ii)=3/4; y(ii)=-t/4+2/4;
ii=ii+N8; x(ii)=3/4; y(ii)=-t/4+1/4;
figure(5); plot(x,y,'k.'); axis off; title('Hilberto kreive');
w=zeros(4,6);
w(1,:)=[  0  50   0 -50  0 50]/100;
w(2,:)=[-50   0  50   0 50 50]/100;
w(3,:)=[ 50   0  50   0 50 50]/100;
w(4,:)=[  0 -50 100 -50  0 50]/100;
for k=1:4, 
 px=zeros(4,length(x)); py=zeros(4,length(y)); 
 for i=1:4,
 p=[w(i,1:2); w(i,4:5)]*[x;y]; px(i,:)=p(1,:)+w(i,3); py(i,:)=p(2,:)+w(i,6); end;
 x=[px(1,:) px(2,:) px(3,:) px(4,:)];
 y=[py(1,:) py(2,:) py(3,:) py(4,:)];
 ox=x(end-N8+1); oy=y(end-N8+1);
 y(end-N8+1:end)=oy-(x(end-N8+1:end)-ox); x(end-N8+1:end)=ox;
figure(k); plot(x,y,'k.'); axis off; title('Hilberto kreive');
end;
