Solution (source code)

= Solution

The call constructs dimensions $(d,w,h)$ along the old $(x,y,z)$ axes. To obtain target dimensions $(w,h,d)$ and make an old layer $z=k\,\texttt{step}$ become a new layer $y'=k\,\texttt{step}$, use the cyclic permutation
$$
\boxed{P=\begin{pmatrix}0&1&0&0\\0&0&1&0\\1&0&0&0\\0&0&0&1\end{pmatrix},\qquad (x,y,z)\mapsto(y,z,x).}
$$
The new coordinate ranges are immediately $[0,w]$, $[0,h]$, $[0,d]$. Its spatial block is <orthogonal> with determinant $+1$, since a three-cycle is an even <permutation>. Hence this is a <proper rotation>, through $-2\pi/3$ about the axis in direction $(1,1,1)$ under the right-hand convention. No <translation> is required.