How do I rotate a 3D array in matlab?
My input data is a matrix n*n*n. I want to rotate it around its center to an arbitrary angle (theta, phi) and have another n*n*n matrix at output (wherever the values are defined, of course).
For example, given
a(:,:,1) = [0 0 0;
0 0 0;
0 0 0];
a(:,:,2) = [0 0 0;
0 0 1;
0 0 0];
a(:,:,3) = [0 0 0;
0 0 0;
0 0 0];
being rotated to [pi/2; pi/2] (thus, 45 deg around Z and 45 deg around x) should produce smth like
a(:,:,1) = [0 0.1 0.5;
0 0.05 0.1;
0 0 0];
a(:,:,2) = [0 0.1 0.05;
0 0 0.1;
0 0 0];
a(:,:,3) = [0 0 0;
0 0 0;
0 0 0];
(Values are approximate).
If there is a built-in function for this? Of what would you suggest me to create it?