I have an opengl arbitrary rotation matrix and would like to remove the X & Y axis, leaving me with only the Z axis?
Is this possible? Any pointers on how to do it?
I have an opengl arbitrary rotation matrix and would like to remove the X & Y axis, leaving me with only the Z axis?
Is this possible? Any pointers on how to do it?
In a rotation that is only around the z-axis, the z axis should remain unchanged. So the above recommendation is sort of the reverse of what you want.
Let's assume you have an arbitrary OpenGL matrix:
Where the t_i elements are translations and the r_jk elements are components of rotation. You want a matrix that looks like this:
Unless the matrix has scaling factors or is close to a singularity, you should be able to get this by just zeroing out the z parts of the matrix and then re-normalizing the columns. Since an OpenGL matrix is column major order:
Just thinking out loud here, but can't you use the matrix to rotate a vector like (1,0,0), then do atan2(y,x) to see how much it's rotated and then build a new matrix to rotate through the Z axis by that much?