# gluLookAt :: Rotation Angle

Im using gluLookAt for my camera, so far so good… I have control over every direction. However I would like to know how I can get the camera xyz rotation angles (0 ~ 360) oriented to the camera start position:

``````cam_pos-&gt;x 	= 0.0f;
cam_pos-&gt;y 	= 0.0f;
cam_pos-&gt;z 	= 1.0f;

cam_t_pos-&gt;x 	= 0.0f;
cam_t_pos-&gt;y 	= 1.0f;
cam_t_pos-&gt;z 	= 1.0f;

cam_up-&gt;x 	= 0.0f;
cam_up-&gt;y 	= 0.0f;
cam_up-&gt;z 	= 1.0f;
``````

How can I do it!?

search the web for “Matrix FAQ” it features examples on euler extraction and lots of other related information

I used the euler extraction method but the readings seems strange… Am I missing something or? there’s my code:

``````    GLdouble mat;
glGetDoublev(GL_MODELVIEW_MATRIX, mat);

float D;
float angle_y = D =  asin( mat);       // Calculate Y-axis angle
float C           =  cos( angle_y );
float angle_x;
float angle_z;
float tr_x;
float tr_y;

if ( fabs( C ) > 0.005 )              // Gimball lock?
{
tr_x      =  mat / C;           // No, so get X-axis angle
tr_y      = -mat  / C;
angle_x  = atan2( tr_y, tr_x ) * RADIANT_TO_DEGREE;
tr_x      =  mat / C;            // Get Z-axis angle
tr_y      = -mat / C;
angle_z  = atan2( tr_y, tr_x ) * RADIANT_TO_DEGREE;
}
else                                 // Gimball lock has occurred
{
angle_x  = 0;                      // Set X-axis angle to zero
tr_x      =  mat;               // And calculate Z-axis angle
tr_y      =  mat;
angle_z  = atan2( tr_y, tr_x ) * RADIANT_TO_DEGREE;
}

// return only positive angles in [0,360]
if (angle_x < 0) angle_x += 360;
if (angle_y < 0) angle_y += 360;
if (angle_z < 0) angle_z += 360;

printf("%f %f %f
", angle_x, angle_y, angle_z);
``````