Thread: rotation conversion

  1. #1
    Registered User
    Join Date
    Feb 2005
    Posts
    61

    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?

    Thanks in advance.

  2. #2
    Crazy Fool Perspective's Avatar
    Join Date
    Jan 2003
    Location
    Canada
    Posts
    2,640
    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
    Last edited by Perspective; 03-17-2005 at 10:14 AM.

  3. #3
    Registered User
    Join Date
    Feb 2005
    Posts
    61
    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.
    Last edited by hannibar; 03-17-2005 at 10:35 AM.

  4. #4
    Registered User
    Join Date
    Mar 2003
    Posts
    580
    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();
    glLoadMatrix(Matrix);
    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
    See you in 13

  5. #5
    Registered User
    Join Date
    Feb 2005
    Posts
    61
    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.

  6. #6
    Crazy Fool Perspective's Avatar
    Join Date
    Jan 2003
    Location
    Canada
    Posts
    2,640
    oh, i see. That sounds terribly innefficient. whats wrong with just loading the matrix onto the stack?

  7. #7
    Registered User
    Join Date
    Mar 2003
    Posts
    580
    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).
    See you in 13

  8. #8
    Registered User
    Join Date
    Feb 2005
    Posts
    61
    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.
    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.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Screwy Linker Error - VC2005
    By Tonto in forum C++ Programming
    Replies: 5
    Last Post: 06-19-2007, 02:39 PM
  2. Dikumud
    By maxorator in forum C++ Programming
    Replies: 1
    Last Post: 10-01-2005, 06:39 AM
  3. Header File Question(s)
    By AQWst in forum C++ Programming
    Replies: 10
    Last Post: 12-23-2004, 11:31 PM
  4. Do I have a scanf problem?
    By AQWst in forum C Programming
    Replies: 2
    Last Post: 11-26-2004, 06:18 PM
  5. Binary Search Trees Part III
    By Prelude in forum A Brief History of Cprogramming.com
    Replies: 16
    Last Post: 10-02-2004, 03:00 PM