• Remix
  • Share
  • New Entry

  • KSSV

  • /
  • Hilbert 3D curve

on 19 Oct 2021
  • 47
  • 106
  • 0
  • 0
  • 274
[x,y,z] = Hilbert(3) ;
% figure('color','k')
plot3(x,y,z,'r')
axis off
function [x,y,z] = Hilbert(n)
% Hilbert 3D curve.
if n<=0
x=0;
y=0;
z=0;
else
[x0,y0,z0]=Hilbert(n-1);
m=.5;
x=m*[m+z0 m+y0 -m+y0 -m-x0 -m-x0 -m-y0 m-y0 m+z0];
y=m*[m+x0 m+z0 m+z0 m+y0 -m+y0 -m-z0 -m-z0 -m-x0];
z=m*[m+y0 -m+x0 -m+x0 m-z0 m-z0 -m+x0 -m+x0 m-y0];
end
end
Image
Remix Tree