Notes:Grid iteration
From Maths
See Modulo operator for a definition of Mod(a,b)
2D grid

Notice the 21st point is back at the origin and the sequence repeats. Direct link
- Mixx(k,m,n):=Floor(Mod(Mod(k,mn),m))
- Mixy(k,m,n):=Mod(k,mn)−Mod(Mod(k,mn),m)m
Then
- Points of the form:
- (Mixx(k,m,n),Mixy(k,m,n))span an m×n grid, for k from 0 to mn−1
- (Mixx(k,m,n),Mixy(k,m,n))
Notice that these coordinates return to the start for count=21 or k=20, this is critical to allowing this to be used in higher dimensions.
3D grid

Notice that after the count is ℓ×m×n (here, 3×8×6) it goes back to the starting point, this is key for using in higher dimensions. Direct link
Suppose we have an ℓ×m×n grid, we can build this using Mixx and Mixy:
- for k∈N0 with 0≤k≤ℓ×m×n−1
- x-coordinate: Mixx(k,ℓ,m×n)
- y-coordinate: Mixx(Mixy(k,ℓ,m×n),m,n)
- z-coordinate: Mixy(Mixy(k,ℓ,m×n),m,n)
In the picture on the right we show a 3×8×6 example, notice that these multiplied give 144 (k=144−1=143), we do 145 (k=144) instead, this gives the diagonal returning back to the 1st point, and is the key property in allowing this concept to extend to higher dimensions (returning to the start, where we would increase the 4th dimension to create a distinct point, if we did so here)
Generalisation
TODO: Explain method, generalise to arbitrary dimensions