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 3 of 3

Thread: Any method to get the angle?

  1. #1
    Junior Member Newbie
    Join Date
    Aug 2004
    Posts
    6

    Any method to get the angle?

    I use the function---glRotatef() to rotate the model, and now I want to know whether the angle which the model rotated is right or not, so I wonder if there any method to get the angle the model actually rotate? Anyone who knows about it please tell me! Thank you very much!

  2. #2
    Intern Contributor
    Join Date
    Apr 2004
    Posts
    57

    Re: Any method to get the angle?

    you could try this:

    Code :
    float oldy = yrot;
    glRotatef(xrot,yrot,zrot);
    //say you want to know the rotation of the y axis:
     
    if (oldy >= yrot) {
    //then you know that it turnes right
    }
    if (oldy <= yrot) {
    //then you know that it turned left
    }
    Does that answer your question? Hope this helps...
    "A Programmer is the same thing as a Psycho, except for one difference----A programmer gets paid to do what he does."*--Brian Jennings

  3. #3
    Intern Contributor
    Join Date
    Apr 2004
    Posts
    57

    Re: Any method to get the angle?

    Woops, After reading your question further i realized that you eman right as in correct, I thought you meant right as in direction. lol.

    you could try this:

    Code :
     
    glRotatef(angle, 0.0f, 1.0f, 0.0f);
     
    //here the float [B]angle[/B]  is the angle of rotation
    or if you want to know the difference between rotation:

    Code :
    float oldangle = angle;
    float amrot;
    glRotatef(angle, 0.0f, 1.0f, 0.0f);
     
    if (oldangle == angle) {
    //rotation didn't change
    }
    elsif (oldangle >= angle) {
    //then it rotated left
    amrot = oldangle - angle;
    //amrot equals the amount of rotation
    }
    else {
    //Obviously if it didn't stay still, or rot left, then it must have rotated right
     
    amrot = angle - oldangle;
    }
    If you need any more help or information about the code that I dumped here just ask...

    Hope this helps...
    "A Programmer is the same thing as a Psycho, except for one difference----A programmer gets paid to do what he does."*--Brian Jennings

Posting Permissions

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