• New Entry

Hilbert Curve

KSSV on 19 Oct 2021
  • 53
  • 83
  • 0
  • 0
  • 279
[x,y]=Hilbert(5);
figure('color','k')
% patch(x,y,'w')
z=zeros(size(x));
c=sqrt(x.^2+y.^2);
surface([x;x],[y;y],[z;z],[c;c],'facec','no','edgec','interp','linew',2);
axis off
function [x,y] = Hilbert(n)
%Hilbert curve
if n<=0
x=0;
y=0;
else
[x0,y0]=Hilbert(n-1);
m=0.5;
x=m*[-m+y0 -m+x0 m+x0 m-y0];
y=m*[-m+x0 m+y0 m+y0 -m-x0];
end
end
Remix Tree