Hello! Every array in the physics memory (1d, 2d, 3d etc) are placed linear. And why you create 3 dimensional array in c++ for example, elements for this array will placed as
0,0,0 ; 1,0,0 ; .... mx-1,0,0; 0,1,0; 1,1,0; ... mx-1,1,0; etc...
the basic formula for poly dimensially arrays to transfer this to 1-dimensially array (or physics memory) for 2 and 3 dimensions:
El[0] ... El[ma] - linear array (for example, this is your map array of any type)
mx - x dimension of array you need to make
my - y dimension of array you need to make
mz - z dimension of array you need to make
for 2 dimensions ma = (mx * my - 1)
for 3 dimensions ma = (mx * my * mz - 1)
register your El array with "ma" elements and use for access this formulas:
for element x,y of 2d array you need to get El[a] element where a = x + y*mx
for element x,y,z of 3d array you need to get El[a] element where a = x + y*mx + z*my*mx
for example, u need array with mx=2, my=3, mz=4. ma = mx*my*mz-1 = 23. 23 is the max index, but not dimension of linear array; really dimension is 24. and for access to element 0,0,0 you need to access El[0]; for access to 1,2,3 you need to access El[23]; for access to 1,0,2 you need to access El[13]
Note that all coordinates in this formulas are started with 0, not with 1! if you want to first index 1, you must replace all x,y and z with (x-1), (y-1),(z-1) and add +1 to all formulas
sorry for my bad english