Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 9 of 9

Thread: glRotatef and rotation around arbitrary axis

  1. #1
    Junior Member Newbie
    Join Date
    Oct 2010
    Location
    IL
    Posts
    4

    glRotatef and rotation around arbitrary axis

    Hi all,

    My primary task to rotate around arbitrary axis, but I can't use glRotatef because some other calculations after transformations to be done. So I need manually transform each vector by rotation matrix. The problem is that my manual matrix taken from here and here is not equal to matrix that glRotatef makes.

    Which matrix glRotatef use, isn't standard one?

  2. #2
    Junior Member Newbie
    Join Date
    Dec 2009
    Location
    India
    Posts
    9

    Re: glRotatef and rotation around arbitrary axis

    You can directly manipulate ModelView matrix. So after all the calculations you can directly set the modelview matrix to OpenGL matrix stack.

    Regards
    Anirban Talukdar

  3. #3
    Junior Member Newbie
    Join Date
    Oct 2010
    Location
    IL
    Posts
    4

    Re: glRotatef and rotation around arbitrary axis

    Quote Originally Posted by Anirban Talukdar
    You can directly manipulate ModelView matrix. So after all the calculations you can directly set the modelview matrix to OpenGL matrix stack.
    OK that fine but my question was, how can I reproduce manually glRotate? Which matrix glRotate uses?

  4. #4
    Super Moderator OpenGL Lord
    Join Date
    Dec 2003
    Location
    Grenoble - France
    Posts
    5,655

    Re: glRotatef and rotation around arbitrary axis


  5. #5
    Senior Member OpenGL Guru
    Join Date
    May 2009
    Posts
    4,719

    Re: glRotatef and rotation around arbitrary axis

    The problem is that my manual matrix taken from here and here is not equal to matrix that glRotatef makes.
    How did you make that determination? I hope you didn't just test the floats to see if they were equal.

  6. #6
    Junior Member Newbie
    Join Date
    Oct 2010
    Location
    IL
    Posts
    4

    Re: glRotatef and rotation around arbitrary axis

    Quote Originally Posted by Alfonse Reinheart
    How did you make that determination? I hope you didn't just test the floats to see if they were equal.
    Actually that what I did .. But before in both cases I loaded identity matrix. Also in both cases I used same rotation vector and angle ...

  7. #7
    Senior Member OpenGL Guru
    Join Date
    May 2009
    Posts
    4,719

    Re: glRotatef and rotation around arbitrary axis

    Actually that what I did
    That's what I figured.

    You can never expect to get binary-identical floating-point values like that. Whatever the driver is doing to compute glRotatef, it's almost certainly not the exact same floating-point code you are using. As such, it will likely not provide the exact same, binary-identical floating-point results.

    Just look at the two matrices, in text form. If they look reasonably close enough (within ~4-5 significant digits), then your rotate function is probably working.

  8. #8
    Junior Member Newbie
    Join Date
    Oct 2010
    Location
    IL
    Posts
    4

    Re: glRotatef and rotation around arbitrary axis

    That describes the difference So the problem somewhere in my code ... I'll check it

    Thanks everyone

  9. #9
    Advanced Member Frequent Contributor
    Join Date
    Jan 2007
    Posts
    965

    Re: glRotatef and rotation around arbitrary axis

    glRotate can go around an arbitrary axis, and you can retrieve the resulting matrix (for further calculation) with glGetFloatv. This won't stall the pipeline as none of this is performed in hardware - only the final multiplication of position by MVP is.

    Are you normalizing your axis vector before doing your own rotation? The spec for glRotate requires this, so if you want your code to match as closely as possible you should also be doing it.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •