#### Archived

This topic is now archived and is closed to further replies.

# Inverse of a rotational matrix

This topic is 6152 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

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

##### Share on other sites
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 );

##### Share on other sites
The inverse of a rotation matrix is simply the transpose of the matrix. Easy heh!

##### Share on other sites
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]

##### Share on other sites
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

##### Share on other sites
Transpose? What is that? I''m not really all that good with matrices, or higher math.

##### Share on other sites
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. :-)

##### Share on other sites
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

##### Share on other sites
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

1. 1
Rutin
46
2. 2
3. 3
4. 4
5. 5

• 13
• 10
• 12
• 10
• 13
• ### Forum Statistics

• Total Topics
632993
• Total Posts
3009763
• ### Who's Online (See full list)

There are no registered users currently online

×