I need a conversion of 3D<->1D index of an array[x][y][z] into array2[i].
I checked this thread at stackoverflow:
and grabbed their solution for
i = x + y*xMax + z*yMax*xMax
But i stumbled uppon the following problem:
Let’s assume i have a 3D “Wall” of the dimensions 1x3x3, which makes :
xMax = 1
yMax = 3
zMax = 3
Now storing those two elements at: [1][0][0] ; [0][1][0] inside array2[i] would result in:
[1][0][0] : i = 1 + 0*1 + 0*3*1 = 1
[0][1][0]: i = 0 + 1*1 + 0*3*1 = 1
Both elements interfere at the same index, what am i doing wrong or missing out?