3D Hilbert Space-filling curve code, can someone help me?

Hi all,
I’m trying to have printed 3D Hilbert curve. I’d like to have some suggestion on python code to use in Blender. I found several codes writte in C but give me sequence for points/coords, what I’d like to have is a “solid costruction” of 3D Hilbert curve.

I’m a quite new in Python, but I have experience in java and C/C++ programming.

Can someone address me to correct “source”?

Thank you in advance!


Best bet is to take the C code and translate it into Python. From a quick search, it looks like you just need to connect point “i” to point “i+1” to form the structure. You could do that by extruding a circle or square along the path.

can you show the equations and a pic may be with the C program
if not long can probably be converted quickly !

happy bl

Some ideas - http://www.tiac.net/~sw/2008/10/Hilbert/

some of the functions don’t work in python
like this one here

def gray_encode( bn ):
assert bn >= 0

assert type( bn ) in [ int, long ]

return bn ^ ( bn / 2 )

anyone has an idea how it could work ?

happy bl


where is the hilbert func ?

can u show complete working script so that other people can haven fun too!