0

I am projecting a 3D matrix of density values into 3 2D planes (ZX,ZY,XY). I then rotate each projection by 3 different angles: Pzx, Pzy, Pxy using the rotation matrix below:

2D Rotation Matrix

How do I convert these 3 separate angles so that I can apply them to a 3D transformation matrix which will rotate the 3D object about X,Y,Z (or Z,Y,X) such as the rotation matrix below:

3D Rotation Matrix about X,Y,Z

To be clear, I do not wish to apply angles Pzx, Pzy, Pxy to the 3D object, but instead calculate what those individual rotations in 2D would translate to in 3D.

1 Answers1

1

This problem yields a system of equations. Let R_3d be the rotation in 3d space, R_xy the rotation in the xy plane, and [*]_xy be the projection of * onto the xy plane. Then for any point v:

I:   [R_3d v]_zx = R_zx [v]_zx
II:  [R_3d v]_zy = R_zy [v]_zy
III: [R_3d v]_xy = R_xy [v]_xy

We see that every coordinate is present in two equations. Let's check the relevant equations for the x-coordinate:

a := alpha, b := beta, c := gamma
I:   cos b cos c x - cos b sin c y + sin b z = sin Pzx z + cos Pzx x
III: cos b cos c x - cos b sin c y + sin b z = cos Pxy x - sin Pxy y

We see that the following relation mus hold for any v (right hand side of both equations):

sin Pzx z + cos Pzx x = cos Pxy x - sin Pxy y

Similar equations exist for the other two coordinates. Only if these conditions are met, an exact 3d rotation can exist. If I'm not mistaken, that's only the case if Pzx=Pzy=Pxy=0. In general, an approximate solution can be calculated. I would suggest a least-squares solution based on the following energy:

E(a, b, c) = Sum { for all v in data set } ( || [R_3d v]_zx - R_zx [v]_zx ||^2
                                           + || [R_3d v]_zy - R_zy [v]_zy ||^2
                                           + || [R_3d v]_xy - R_xy [v]_xy ||^2 )

And the optimal rotation parameters are:

{a, b, c}* = arg min {a, b, c} E(a,b,c)

This solution will minimize the distance of the two projections of corresponding points.

Unfortunately, the problem is not a linear least-squares problem which would be easy to solve. Instead, iterative methods can solve this problem (e.g. Levenberg–Marquardt). Look for an implementation of that algorithm in your programming language, plug in the energy and solve for the optimal rotation parameters.

Nico Schertler
  • 32,049
  • 4
  • 39
  • 70