PDA

View Full Version : Any method to get the angle?



helenyyh23
11-22-2004, 07:13 PM
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!

Me6
11-23-2004, 08:17 AM
you could try this:



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...

Me6
11-23-2004, 08:28 AM
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:




glRotatef(angle, 0.0f, 1.0f, 0.0f);

//here the float angle is the angle of rotation

or if you want to know the difference between rotation:



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...