| Version 2 (modified by , 17 years ago) (diff) |
|---|
Numbering tiles
If we want a straightforward way to linearly index tiles without necessarily knowing the image size, we can use the following enumeration:
| 0 | 1 | 3 | 6 | 10 | 15 | 21 |
| 2 | 4 | 7 | 11 | 16 | 22 | 29 |
| 5 | 8 | 12 | 17 | 23 | 30 | 38 |
| 9 | 13 | 18 | 24 | 31 | 39 | … |
| 14 | 19 | 25 | 32 | 40 | … | |
| 20 | 26 | 33 | 41 | … | ||
| 27 | 34 | 42 | … |
One way to generate these values is using the Cantor polynomial:

Efficiently inverting that polynomial is not trivial. Here is one way to do it:

