It is merely an extention of what you are doing with some additional options.

Suppose you have a 2d matrix of 5 columns and 5 rows.

You can rotate it clockwise or counterclockwise.

You can map the cells before rotation to the cells after rotation. Not a big problem.

If you extend your matrix to a 3d and still have 5 rows and 5 columns & 5 tuples (or plies), you have additional possibilities.

You can rotate clockwise or counterclockwise.

You can rotate the top towards or away from you.

You can rotate the right side towards or away.

With each increase in dimension 4d, 5d, 6d you are given additional possibilities for the rotation of each facet.

Just wondering, do you have an application for rotating a cube or is this just for "for the fun" of being able to do it?

I have worked with a matrix of 48 rows and 48 columns.

Rotated it clockwise & counterclockwise.

Transposed it.

Reflected it.

And a few other things.

However, I've never had any reason to shift the cells in a 3d matrix of any size -- excluding the [1x1x1] matrix.

If you will post your method of rotating a 3d matrix (a cube) then I will provide you an algorithm for rotating a 4d matrix.

ok.