I have a set of Hilbert values (length from the start of the Hilbert curve to the given point).
What is the best way to convert these values to 3D points? Original Hilbert curve was not in 3D, so I guess I have to pick by myself the Hilbert curve rank I need. I do have total curve length though (that is, the maximum value in the set).
Perhaps there is an existing implementation? Some library that would allow me to work with Hilbert curve / values? Language does not matter much.
Not an answer about 3D conversion, but there is a nice algorithm and discussion of Hilbert values here Two-dimensional spatial hashing with space-filling curves
From MIT
If I get your question right you have some curve-length distance
l
from start point of Hilbert 3D curve and want to get coordinates corresponding to such point.if you pre-generate the whole 3D Hilbert curve (covering unit cube) as a Polyline then all the sequenced points are at same distance between previous and next point. So you can compute your point using piecewise linear interpolation.
This is how I generate and render 2D/3D Hilbert curve in C++:
I used mine dynamic list template so:
List<double> xxx;
is the same asdouble xxx[];
xxx.add(5);
adds5
to end of the listxxx[7]
access array element (safe)xxx.dat[7]
access array element (unsafe but fast direct access)xxx.num
is the actual used size of the arrayxxx.reset()
clears the array and setxxx.num=0
xxx.allocate(100)
preallocate space for100
itemsBut you can use dynamic or even static 1D array instead as the number of points of Hilbert curve is easily computable (
m
at the start of each Hilbert function).Usage is simple just do something like this:
Where
n
is number of iterations andpnt
is linear list of(x,y,z)
coordinates for each point (3 numbers per point). the start position and initial size is set to cover cube centered around(0,0,0)
with half size0.8
<-0.8,+0.8>
.Now just compute unit length between points, index of closest Hilbert curve point to the left and parameter (distance to it) from that just linearly interpolate. Here C++ example:
2D preview:
3D preview: