Search code examples
iphoneopengl-esglu

Iphone OpenGL : gluLookAt X,Z to rotation (360) : Heading angle


The OpenGL program I am writing uses a port of glULookat to control the camera

To rotate I have the following code

case ActionTurnLeft: 
center[0] = eye[0] + cos(-SPEED_TURN)*v[0] - sin(-SPEED_TURN)*v[2]; 
center[2] = eye[2] + sin(-SPEED_TURN)*v[0] + cos(-SPEED_TURN)*v[2]; 


break;

case ActionTurnRight: center[0] = eye[0] + cos(SPEED_TURN)*v[0] - sin(SPEED_TURN)*v[2]; center[2] = eye[2] + sin(SPEED_TURN)*v[0] + cos(SPEED_TURN)*v[2];

My question is how do I get the rotation angle in degrees?

Updated : Tried this and it gave me -572 ish to 572

float rotAngleDegs;
float PI = 3.1415926535897;
rotAngleDegs = (cos(-SPEED_TURN)*v[0] - sin(-SPEED_TURN)*v[2]) * 180 / PI;
NSLog(@"%f", rotAngleDegs);

Solution

  • Incrementing a float by rotation +=2.865; seemed to actually work lol