# rotation conversion

• 03-17-2005
hannibar
rotation conversion
I'm trying to use ODE together with openGL.
Ode outputs its rotation as a 3*3 matrix (yaw pitch roll).
I want to convert it to a format that openGL can use :

(amount, x, 0, 0)
(amount, 0, y, 0)
(amount, 0, 0, z)

Does anyone know how to do that?

• 03-17-2005
Perspective
go to http://mathworld.wolfram.com/RotationMatrix.html

look at matrices (5), (6), and (7).

Take each of the matrices and make them 4x4 by adding a row and colum of (0, 0, 0, 1).
so..
x x x 0
x x x 0
x x x 0
0 0 0 1
(where the x's represent the matrices linked to above)

These are matrices opengl can use, BUT!!! make sure you store them in column major order!!!!

edit: btw, your going to need to use glLoadMatrix*() to actually push your matrix on to the stack
• 03-17-2005
hannibar
I think you misunderstood.
What I have is the multiplication of matrices (5), (6), and (7).
What I want to do is to convert them to what I described in the first post (to be able to apply glRotate*() on it).

So what I need is the rotation around the x, y, and z axis.
• 03-17-2005
Darkness
All you have to do is make sure it's in column-major format, set the matrix mode to glModelView, and call glLoadMatrix. If you don't want to destroy the current modelviewmatrix, call glPushMatrix first. So it looks like this:

glMatrixMode(GL_MODELVIEW);
glPushMatrix();
do stuff...
glPopMatrix();

Matrix is a single dimensional 16 element array of floating points which represents the matrix in column major order. Your job is to create the appropriate array.

Otherwise, you have to extract the angles from the matrix from ODE in order to call glRotate
• 03-17-2005
hannibar
Quote:

Originally Posted by Darkness
Otherwise, you have to extract the angles from the matrix from ODE in order to call glRotate

That is exactly what I want to do (I need thise angles, and not a matrix), but I just don't know how.
• 03-17-2005
Perspective
oh, i see. That sounds terribly innefficient. whats wrong with just loading the matrix onto the stack?
• 03-17-2005
Darkness
I honestly don't even remember how to do that. To the original poster, just do what perspective and I said...it has the EXACT same final effect (glrotate operates on the modelview matrix anyway).
• 03-18-2005
hannibar
Quote:

Originally Posted by Perspective
oh, i see. That sounds terribly innefficient. whats wrong with just loading the matrix onto the stack?

I need it for a few other operations. To be honest, a lot of code in my program depends on these values. Maybe that's a bad decision, but the code has grown a bit to large to change it now. Anyway this is something I will keep in mind for my next programming project.
Quote:

I honestly don't even remember how to do that. To the original poster, just do what perspective and I said...it has the EXACT same final effect (glrotate operates on the modelview matrix anyway).
It will indeed have the effect I want for the drawcode, but for the reason I posted above I will still need these values for other things.

A solution would be to store everything as a matrix, and change all the functions that us the axis-angles to use the matrices. But This would require a major rewrite of my code, and I don't know if that's worth it.