How to rotate a 3D array in matlab?
My input is a n * n * n matrix. I want to rotate it around its center by an arbitrary angle (theta, phi) and have a different n * n * n matrix at the output (wherever the values are determined, 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];
rotates to [pi / 2; pi / 2] (thus, 45 degrees around Z and 45 degrees around x) should form smth, as
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];
(approximate values).
If there is a built-in function for this? What would you suggest me to create it from?
source
share