Page 1 of 1

Stupid Question : Angles problem

Posted: Thu Apr 16, 2009 7:42 am
by Linaxys
Hello,
When I rotate my node on the left, it gets a negative number, like -1, then it goes -360, -475, -900, -5584,...

How to do like this : -1, -1, -1, I mean, I would like to have the real values between 0 and 360 when I do getRotation();

Thanks.

Posted: Thu Apr 16, 2009 7:47 am
by hybrid
What code do you use to rotate the node and display the rotation?

Posted: Thu Apr 16, 2009 7:53 am
by Linaxys
Hello hybrid,
I'm using like this :

Code: Select all

vector3df objRot = obj->getRotation();
objRot.Y += 2.5f;
obj->setRotation(objRot);

Posted: Thu Apr 16, 2009 8:55 am
by shadowslair
This will wrap your angle in the 0-360 diapason. As far I understand this is what you want.

Code: Select all

float angle;

 if(angle>360)    angle-=360;
 if(angle<0)      angle+=360;
Put it before applying the rotation to the node:

Code: Select all

vector3df objRot = obj->getRotation();
objRot.Y += 2.5f;

if(objRot.Y>360)   objRot.Y-=360;
if(objRot.Y<0)      objRot.Y+=360;

obj->setRotation(objRot);