Multiply series of image by 3D rotate matrix

I have a series of 2D image (in fact it’s slices of image) : [series of images, H, W]

and I want to multiply it with 3D rotate matrix, what is the easy way to do it?

And if I even need a 3D matrix and not 2D.

what I’m trying to do is like to rotate a cube-like in this picture: https://math.stackexchange.com/questions/1327721/how-to-shift-an-object-to-rest-on-the-xy-plane