Inverse of a rotational matrix

Started by
7 comments, last by hooded_paladin 22 years, 4 months ago
I''m trying to do environment mapping right, but the sphere refelction does not rotate with the camera. Someone told me I need to find the inverse of the rotational matrix and put it into the texture matrix. 2 questions 1) is this the right way to do it? and 2) if so, then how? Thanks
______________________________Pretty guy for a white fly.
Advertisement
Firsly, I have no idea whether that is the right method or not.

There are many ways to invert matrices, but as far as I am aware, with orthogonal matrices, the inverse is equal to it''s transpose. Since all the transformation matrices ( translate, rotate and scale ) are orthogonal, then the inverse is simply it''s transpose.

When you say "put it" into the texture matrix, I assume you mean multiply, to do this select the texture matrix and use glMultMatrix* like so:

glMatrixMode( GL_TEXTURE );
glMultMatrixf( inverse_rotation_matrix );
If at first you don't succeed, redefine success.
The inverse of a rotation matrix is simply the transpose of the matrix. Easy heh!
Are you sure the inverse is the transpose when doing rotation? I thought the inverse was just negating the angles in the case of rotation. Like:

if R is:

[cos(theta) sin(theta) 0 0]
[-sin(theta) cos(theta) 0 0]
[0 0 1 0]
[0 0 0 1]

then the inverse is:

[cos(-theta) sin(-theta) 0 0]
[-sin(-theta) cos(-theta) 0 0]
[0 0 1 0]
[0 0 0 1]


The rotation matrix is orthogonal, ALL othogonal matrices have their transpose equal to their inverse. Also, since the cosine terms are on the top left to bottom right diagonal, it's true that:

R -1( theta ) = R ( -theta ) = R T( theta )

Think of like this, to get back to the previous position after rotating by an angle theta, you need to rotate by and angle -theta. Since cosine is symetrical around the y axis, it won't make a difference, so it's only the sin terms that do. And if you think about it, -sin( theta ) is the same as sin( -theta ). So if you swap all the sin terms with it's opposite ( so sin turns to -sin, and -sin turns to sin ), you will find that it ends up being the transpose of the original matrix.



[EDIT: formatting]

Edited by - python_regious on December 18, 2001 10:15:14 AM
If at first you don't succeed, redefine success.
Transpose? What is that? I''m not really all that good with matrices, or higher math.
______________________________Pretty guy for a white fly.
Ahh..thanks Python. I was the one that posted about the inverse being the cos(-theta) thing. I see now that the transpose gives you pretty much the same answer. duhhh on my part. Thanx. :-)

Just transposing the modeview matrix is not enough, I believe. If the matrix contains translations, you get into trouble. It should be the rotation part only, and transposed of course.

If the modelview matrix looks like this:
    [ a d g x ][ b e h y ][ c f i z ][ 0 0 0 1 ]a-i = rotation partx-z = translation part  You should not upload the transpose of that matrix, but rather the transposed rotation part only.      [ a b c 0 ][ d e f 0 ][ g h i 0 ][ 0 0 0 1 ]    


quote:
Transpose? What is that? I'm not really all that good with matrices, or higher math.

A transposed matrix is a matrix that is rotated about is't main diagonal. An element at (m, n) is places at (n, m). Basically, rows and collumns are swaped.

Edited by - Brother Bob on December 18, 2001 4:59:34 PM
quote:Original post by Anonymous Poster
Are you sure the inverse is the transpose when doing rotation? I thought the inverse was just negating the angles in the case of rotation. Like:

if R is:

[cos(theta) sin(theta) 0 0]
[-sin(theta) cos(theta) 0 0]
[0 0 1 0]
[0 0 0 1]

then the inverse is:

[cos(-theta) sin(-theta) 0 0]
[-sin(-theta) cos(-theta) 0 0]
[0 0 1 0]
[0 0 0 1]




What you are saying is identical to the transpose. Remember that: sin(-x) = -sin(x) and cos(-x) = cos(x). Therefore -sin(-theta) becomes sin(theta) and sin(-theta) becomes -sin(theta). Also both cos(-theta) become cos(theta). So the inverse you describe is identical to the transpose!
Math is great isn't it?

EDIT: DOH! python_regious already posted this but I overlooked his post. I need some sleep.

Edited by - Scarab0 on December 18, 2001 5:35:43 PM
Dirk =[Scarab]= Gerrits

This topic is closed to new replies.

Advertisement