Invert One Axis in Rotation Matrix

Started by
12 comments, last by RobTheBloke 13 years ago
I'm not sure but I have the impression that another conceptual misunderstanding is underway here. It seems me that space mirroring and rotation inversion are confused.

Multiplying a column / row of the basis matrix means a mirroring in 1 dimension of the space. It is the same as applying a scale matrix where one of the factors is -1.

When looking at a rotation matrix, you'll notice that there are cosine and sine terms inside. E.g.


[ c s 0 ]
[ -s c 0 ]
[ 0 0 1 ]

(where c means cos(angle) and s means sin(angle)) is a simple, z-axis rotation matrix.

Now, inverting the rotation can be achieved by negating the angle. But look at the terms then, considering that
cos(angle) == cos(-angle)
sin(angle) == -sin(-angle)
Hence you cannot yield in an inverse rotation by negating one of the columns / rows!

Is this the problem you've encountered?

BTW: The term "axis" may mean a column / row of the basis (orientation matrix) and hence a dimension in a space, or else a pivot for a rotation. Both may be coincident (i.e. in Euler rotations) but are not the same.
Advertisement
Ok, I guess I can't do directly from the matrix ... I will try to get euler angles and create a new matrix ...
It appears the gyroscope is providing you with a left-hand system and you're using OGL as a right-hand system.

Try doing the rotation in the gyroscope's system, rather than OGL. As mentioned above, you just scale the x-axis vector. However, you have to apply that scaling both before and after you do the rotation.

I.e., create a scale matrix for scale factors ( -1, 1, 1 ); scale the x-axis by -1.

Your_matrix = scaleMatrix * gyroMatrix * scaleMatrix

Note: this is for a rotation matrix only, before your multiply by the OGL translation.

Application of the first scaleMatrix moves into gyro space. The gyroMatrix applies the rotation. The second scaleMatrix moves back into OGL space. I believe the second scaling matrix is what you're missing.

EDIT: Good heavens! Just noticed the OP posting date. Guess this is a bit late.

Please don't PM me with questions. Post them in the forums for everyone's benefit, and I can embarrass myself publicly.

You don't forget how to play when you grow old; you grow old when you forget how to play.


Ok, I guess I can't do directly from the matrix ... I will try to get euler angles and create a new matrix ...


^^ What buckeye said ^^ ..... for that is the correct way ;)

This topic is closed to new replies.

Advertisement