View Full Version : rotation and matrix inverse

huangzl99

08-30-2001, 06:21 PM

If you rotate an object around its Y-axis, you'll find that the X- and Z-axes rotate with the object. A subsequent rotation around one of these axes rotates around the newly transformed axis and not the original axis.

I want to perform transformations in a fixed coordinate system rather than the object¡¯s local coordinate system.

can anybody give me some hints?( I don't want to use quaternion.)

in opengl, how to perform matrix inverse?

Korval

08-30-2001, 06:33 PM

I'll answer your second question first. OpenGL is not a matrix library. It has no facility for computing matrix inverses.

As for rotating around a "fixed" coordinate system... it all depends on what you are trying to accomplish. I suspect you're trying to perform Euler angle rotations. That is, you have a rotation about each X, Y, Z axes that you want to apply to an object. The best way to do this is decompose the X,Y,Z rotations into two separate angle/axis rotations. I've written something about how to do this elsewhere on this board, so just do a search on Euler angles.

huangzl99

08-30-2001, 08:17 PM

Originally posted by Korval:

I'll answer your second question first. OpenGL is not a matrix library. It has no facility for computing matrix inverses.

As for rotating around a "fixed" coordinate system... it all depends on what you are trying to accomplish. I suspect you're trying to perform Euler angle rotations. That is, you have a rotation about each X, Y, Z axes that you want to apply to an object. The best way to do this is decompose the X,Y,Z rotations into two separate angle/axis rotations. I've written something about how to do this elsewhere on this board, so just do a search on Euler angles.

hi Korval, I search the entire forum, but can't find what you have posted on this topic, will you explain me a detail?

do you mean using Quaternion? I think there will have other way to work out. please let me know in detail.

many thanks

Jerry

Korval

08-31-2001, 09:28 AM

Your problem is best stated like this:

I have a model in an orientation (we will call it model space). I have a new orientation for it (world space). How do I transform it there?

Pick two axes in model space. One of them should be the "front" (if your model has a front. Otherwise, it doesn't matter). The other is the "up" (once again, if your model has a natural up).

Now, calculate where the "front" and "up" axes are pointing in world space. All this requires is applying your Euler angle rotations to these axes by hand. I won't go into it, but it shouldn't be too tough to figure out.

Now that you have the initial front/up vectors and the final front/up vectors, you just need to rotate them into those positions.

Take the cross product between the initial and final front vectors. This vector is the axis of rotation. The angle should be the acos(Dot(initial_front, final_front)). So, generate the rotation matrix for getting there (ie, glRotatef(angle, axis)).

It would be best to generate this rotation matrix yourself, too, as we need to transform a vector by it. So, take this matrix, and transform the initial_up vector by this matrix. This becomes the transformed_up.

Now, you do a second rotation. The axis for this rotation is the final_front vector. The angle is acos(Dot(transformed_up, final_up)). So, call glRotatef again.

Powered by vBulletin® Version 4.2.2 Copyright © 2015 vBulletin Solutions, Inc. All rights reserved.