Search code examples
openglopengl-compat

Given a projection matrix, how can I get the field of view angle in OpenGL?


With the function

void gluPerspective(GLdouble fovy,  GLdouble aspect,  GLdouble zNear,  GLdouble zFar);

I am able to set the perspective projection matrix according to a certain field of view angle. Given a projection matrix, how can I get the field of view angle in OpenGL?


Solution

  • Look at gluPersperctive

    In the matrix you see M[1][1] = f and f=cotang(fov/2) = 1 / tan(fov/2)

    So just pick the element at [1][1] and then fov = 2·acotan(1/f)