# Rotating a 3D image

I've got a 3D image of non-isotropic voxels, to which I'm applying a general rotation. How could I go about determining an appropriate voxel size for the rotated image? I need to minimize loss of information, but avoid too much supersampling to keep the image from getting too big.

-

3D is a bit out of my depth. If it were 2D I'd choose pixel aspect ratios in the rotated image such that the ratio of sampling rates is approximately equal to the rate at which you are intersecting scan lines in the original image.

I'm making this up as I go along, so let me work an example first:

Suppose my pixels are 16 units wide and 1 unit high. No matter how much I rotate I'd like the resulting pixels to have an area of about 16 units squared. If I rotate by $\pi/2$, I'd like my new pixels 1x16. If I rotate by $\pi/4$, I'd like my new pixels to be 4x4.

So more generally, given an initial image with horizontal pixel width $x_0$ and vertical pixel height $y_0$, and a rotation of angle $0 \le\theta\le\pi/2$.

My new horizontal scan lines are going to intersect the vertical scan lines from the original image at a rate of $\frac{1}{x_0}\cos\theta$ per unit length and intersect the horizontal scan lines from the original image at a rate of $\frac{1}{y_0}\sin\theta$ per unit length.

Likewise, my new vertical scan lines are going to intersect the original horizontal scan lines at a rate of $\frac{1}{y_0}\cos\theta$ and the original vertical scan lines at a rate of $\frac{1}{x_0}\sin\theta$.

So I'd like my aspect ratio to be $$\frac{x_\theta}{y_\theta} = \frac{x_0 \cos\theta + y_0\sin\theta}{y_0\cos\theta + x_0\sin\theta}$$ and my new pixel area to be $$x_\theta y_\theta = x_0 y_0.$$

I have no idea how to best deal with the round-off errors, since you probably need the aspect ratios to be rational and the pixel areas to be integers. Also note that I haven't proved anything, just come up with some formulas for aspect ratio that match intuition at $\theta = 0$, $\theta = \pi/2$, and $\theta=\pi/4$.

-