Hello,

I have a 3x3x3 matrix with values hanging from 1 to 27.

The order is this:

Is there an easy way to compute the indexes given the value?Code:m[0][0][0] = 1; m[0][0][1] = 2; m[0][0][2] = 3; m[0][1][0] = 4; m[0][1][1] = 5; m[0][1][2] = 6; . . . m[1][0][0] = 10; m[1][0][1] = 11; m[1][0][2] = 12; . . . m[2][2][0] = 25; m[2][2][1] = 26; m[2][2][2] = 27;

For example, I know that the first index can be found by dividing the value by 9.0:

What about the second and the third indexes? I couldn't find a pattern in the numbers, and I didn't want to iterate through the matrix (the indexes will be calculated many times).Code:const int firstIndex = ceil(value / 9.0) - 1;

The other option is to create arrays where the values will be indexes and the matrix indexes will be the values. I'm not sure if it is the best way though, so I'd really appreciate any advice on this.

Thanks in advance.