Generalized Hilbert ('gilbert') space-filling curve for arbitrary-sized 2D rectangular grids. Takes a discrete 2D coordinate and maps it to the index position on the gilbert curve.
(x, y, w, h)
| 7 | |
| 8 | |
| 9 | def gilbert_xy2d(x, y, w, h): |
| 10 | """ |
| 11 | Generalized Hilbert ('gilbert') space-filling curve for arbitrary-sized |
| 12 | 2D rectangular grids. Takes a discrete 2D coordinate and maps it to the |
| 13 | index position on the gilbert curve. |
| 14 | """ |
| 15 | |
| 16 | if w >= h: |
| 17 | return gilbert_xy2d_r(0, x, y, 0, 0, w, 0, 0, h) |
| 18 | return gilbert_xy2d_r(0, x, y, 0, 0, 0, h, w, 0) |
| 19 | |
| 20 | |
| 21 | def sgn(x): |
no test coverage detected