Formulas in the Readme
Closed this issue · 2 comments
Hi! I don't know any other way to notify this. This caused me slight confusion. The readme says that the hybercube has a side length of 2^p, and that the distances are indexed from 0 to 2^(N p) - 1. But really it seems that the side length of the cube is 2^p - 1, and the points are indexed from 0 to 2^(N p).
Thanks for raising the issue @Toast-b ! Yea, I could have done better with the description. If we concentrate on the image in the README.rst (https://github.com/galtay/hilbertcurve/blob/develop/n2_p3.png) and examine the n=2, p=3 curve (the black hilbert curve) then we have z = 2^(n * p) = 2^(3*2) = 2^6 = 64. The points on the black line are labeled 0 to 63 which is what I meant by "the distances are indexed from 0 to 2^(N p) - 1". If we consider each labeled point along the curve to be the center of a unit hypercube then we also have a side length of 2^p = 2^3 = 8 for the total hypercube (i.e. square with n=2). This is not the same (as you point out) as the straight line distance from (x_0=0, x_1=0) to (x_0=7, x_1=0) which is 2^p - 1 = 7. I think the visualization might be improved by shifting it a half unit forward in each dimension so that the grid lines coincide with the unit hypercube boundaries (although then the coordinates of each labeled point would be half-integers). I'll think about it and update ... maybe just adding hypercube boundaries in a light color would help more. :)
Indeed, I was off-by-one with the indexing, I was thinking hastily.
With the cube size, what you say makes complete sense, it makes sense to "embed" the nodes in the unit cubes. What I was doing, I wanted to scale the cube to have have "physical" size one unit cubed. Then I realized I have to scale with 1/(2^p - 1) and not with the formula in the readme. It wasn't what I expected. :)