Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Page 1 of 2 12 LastLast
Results 1 to 10 of 13

Thread: Rotation functions needed

  1. #1
    Junior Member Newbie
    Join Date
    Aug 2001
    Location
    Whangarei , New Zealand
    Posts
    29

    Rotation functions needed

    there is only one GLFunction to rotate objects. I would like to see a function added to rotate (Z-angle, Y-Angle, X-Angle) to rotate objects around axises

  2. #2
    Junior Member Regular Contributor
    Join Date
    Aug 2000
    Location
    FRANCE
    Posts
    115

    Re: Rotation functions needed

    But... isn't that what the glRotate function already does? You specify an angle of rotation and an axis of rotation. What other kind of rotation is there ?

  3. #3
    Member Regular Contributor
    Join Date
    Jun 2000
    Location
    Karlsruhe, Germany
    Posts
    360

    Re: Rotation functions needed

    There is no single opengl function to rotate objects, but there's a function (glRotate) to compute a rotation matrix and multiply it onto the matrix stack. It not that hard to write your own function to compute the rotation matrix if you don't like opengl's.

    -Lev

  4. #4
    Junior Member Newbie
    Join Date
    Aug 2001
    Location
    Whangarei , New Zealand
    Posts
    29

    Re: Rotation functions needed

    Originally posted by Olive:
    What other kind of rotation is there ?
    3ds max uses 2 types Quaternion & EulerAngles
    EulerAngles is like this Rotate Z degrees on Z axis then Rotate X degrees on X axis then Rotate Y degrees on Y axis. The axises are world axises not local.
    Quaternion I dont understand

    Originally posted by Lev:
    not that hard to write your own function to compute the rotation matrix.
    -Lev
    I dont have a clue where to start, I am self taught so there are gaps in my mathmatical ability, can you help me write a conversion from EulerAngles to what OpenGL uses.

  5. #5
    Senior Member OpenGL Guru
    Join Date
    Mar 2001
    Posts
    3,576

    Re: Rotation functions needed

    "EulerAngles is like this Rotate Z degrees on Z axis then Rotate X degrees on X axis then Rotate Y degrees on Y axis."

    Then do that. glRotate about the Z axis, then glRotate about the X axis, then glRotate about the Y axis.

  6. #6
    Junior Member Newbie
    Join Date
    Aug 2001
    Location
    Whangarei , New Zealand
    Posts
    29

    Re: Rotation functions needed

    Originally posted by Korval:
    "EulerAngles is ..."

    Then do that...
    doing that in Open GL is not posible because it replaces 1 rotation with the next,
    Euler rotates the origonal model on the Z axis to create a copy, that copy is then rotated on the X axis to create A second Copy The Second Copy is rotated on the Y axis to create the model to be rendered,
    of coarse the code only keeps the final result and the original.

  7. #7
    Advanced Member Frequent Contributor
    Join Date
    Apr 2000
    Location
    Adelaide, South Australia, Australia
    Posts
    765

    Re: Rotation functions needed

    it has to be read bottom up, 'cause thats the order of operations, but... surely this is doing EXACTLY like you describe?
    <shrugs>

    Code :
    glLoadIdentity();
     
    /* ... is rotated on the Y axis to create the model to be rendered, */
     
    glRotate(yaxis, 0.0, 1.0, 0.0);
    glPushMatrix();          /* copy rotation */
     
    /* ... that copy is then rotated on the X axis to create A second Copy The Second Copy */
     
    glRotate(xaxis, 1.0, 0.0, 0.0);
    glPushMatrix();          /* copy rotation */
     
    /* Euler rotates the origonal model on the Z axis to create a copy */
    glRotate(zang, 0.0, 0.0, 1.0);
    glPushMatrix();          /* copy rotation */

  8. #8
    Junior Member Regular Contributor
    Join Date
    Aug 2000
    Location
    FRANCE
    Posts
    115

    Re: Rotation functions needed

    Originally posted by King Fuzzy:
    3ds max uses 2 types Quaternion & EulerAngles
    EulerAngles is like this Rotate Z degrees on Z axis then Rotate X degrees on X axis then Rotate Y degrees on Y axis. The axises are world axises not local.
    Quaternion I dont understand
    Ok. I should've made myself clearer. Quaternions are another mean for mathematically representing a rotation. You can see them like complex numbers extended in 3D. And just like complex numbers can represent rotations in 2D, quaternions can represent rotations in 3D.

    Euler angles is just a combination of three rotations.

    Another way to represent a rotation is with a 3x3 matrix.

    But however you represent a rotation, it still "visually" ends up to a rotation of a certain angle around a 3D axis. If you can specify those two parameters you can code any rotation you want.

    Some representations offer benefits that others don't in terms of interpolation, readability (quaternions and matrices are unreadable), compacity, available mathematical operations, etc...

    Sorry for the long blurb. Over and out.

  9. #9
    Junior Member Newbie
    Join Date
    Aug 2001
    Location
    Whangarei , New Zealand
    Posts
    29

    Re: Rotation functions needed

    Thankyou John, I hadnt come across the glPushMatrix Command yet
    I have only been programing OpenGL fo about 5 days now

    Olive, I dont know how to calculate the axis and angle to rotate an object to where I want it, I have lerned most of my mathmatical ability by my self, so there are major gaps in my ability.
    I also used to program on C64 and Amiga so there are also conflects in the terminoligy I have lerned (Microsoft causes some with itself) even opengl causes confusion with some of the terms it uses, like 'Name', refering to a number instead of using the term 'ID'

    This forum is called 'Sugestions for next Release', So do you think more Rotation functions would be a good addition for the next release?

  10. #10
    Junior Member Regular Contributor
    Join Date
    Aug 2000
    Location
    FRANCE
    Posts
    115

    Re: Rotation functions needed

    No, I don't think so. Being able to specify a matrix or an axis/angle is enough. I think where were previous discussions about whether or not to give a quaternion interface to the glRotate functions a while ago, so you can search through the archive of this forum.

    Maybe glRotatefv and glTranslatefv functions would be nice...?

    [This message has been edited by Olive (edited 08-24-2001).]

Posting Permissions

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