Rotation Inversion

Hi Guys,

This may be a simple problem but it is driving me crazy. I have an application that simulates a camera hanging in outer space. It’s rotation is controlled by the joystick and a quaternion is used to store the camera’s current orientation, and have a function that translates the quaternion to an OpenGL transformation matrix.

My problem is that to position the camera, I have to invert the matrix (since I want the quaternion to represent the camera’s orientation rather than a camera transformation), but whenever I pull up on the joystick, the resulting change depends on the current heading of the object. It will be something between a pitch and a roll change. I’ve tried all sorts of inverses, from getting the conjugate of the quaternion, or transposing the resulting transformation matrix (transposing should’ve worked since there was no scaling or translating) and when that didn’t work I did a proper inverse of the transformation matrix instead of a transpose and they all do the same thing.

This could be a problem with the Euler angle order but I can’t see how the angle order applies to ‘quaternion to matrix’ conversion.

If sombody could tell where I could’ve gone wrong or an easy way to convert a matrix from moving the local coordinates to a certain orientation to moving the global coordinates to a certain orientation position. Not sure if that made sense but I’ve done my best to explain.

rotation inversion via transposition always worked for me … all i can say, remember opengl uses a right-handed reference frame, so watch out for wrong signs in you math.
also, for little increments, order of euler angles are not important… moreover if they are under control of the user.

Rotation transform is orthometric.In other words, a rotation matrix is an orthometric matrix.Here’re some features among orthometric matrix.One of them is that the inverse matrix of a orthometric matrix is its transposition.So you can simply transpose your rotation matrix in order to obtain an inversed transform.

Your problem sounds more like a pre-/postmultiplication problem when manipulating the quaternion.

Try to change the multiplication order in the routine that updates the quaternion.

Thanks for your help guys, I found the problem, it was quaternion multiplication order. After I swapped the order, either a transpose of the matrix or multiplying the imaginary terms of the quaternion by -1 worked.