I have a rotation matrix representing the translation from a phone's coordinate system to the world. The Z axis of the world coordinate system points directly up at the sky, and X points east, Y north.
I want to track the rotation while disregarding compass heading, because I am using the rotation to calculate phone tilt relative to the viewer's line of sight. Approximate of course, assuming the viewer is holding the phone position roughly in place relative to the height of their head.
If I convert to ZXY Euler angles, I could zero out the azimuth and convert back to a matrix or quaternion, but then I've introduced gimbal lock. Is there a way I can directly cancel the Z-axis portion of the rotation directly?