• Remix
  • Share
  • New Entry

  • Kaname Teratsuji

  • /
  • lines that think they're squares (L-system based Hilbert curve)

on 5 Oct 2021
  • 2
  • 37
  • 1
  • 0
  • 276
a=1;
g=0;
x=0;
y=0;
axis equal
axis off
for i=1:8
b=[];
for j=1:length(a)
switch(a(j))
case 1
b=[b,4,2,3,5,1,3,1,5,3,2,4];
case 2
b=[b,5,1,3,4,2,3,2,4,3,1,5];
otherwise
b=[b,a(j)];
switch(a(j))
case 3
m=x+cos(g);
n=y+sin(g);
line([x,m],[y,n],'Color','k')
x=m;
y=n;
case 4
g=g+pi/2;
case 5
g=g-pi/2;
end
end
end
a=b;
y=x;
end
Remix Tree