I'm looking into computing the vertical Field-of-View (FOVy) based on the projection parameters of my camera. From this source, I've found an equation that seems to work.

float FOVyForProjection(const float height, const float nearClip, const float farClip)
    // From http://paulbourke.net/miscellaneous/lens/
    // vertical_field_of_view = 2 atan(0.5 height / focal_length)
    const float focalLength = (farClip - nearClip);
    const float fovy = 2.0f * std::atan((height * 0.5f) / focalLength);
    return (fovy);

However, the author of the last link is talking about actual cameras and lenses, measured in millimeters, so I'm not sure if my interpretation is valid. Is the above function correctly computing the y-FOV based on the window height and near/far planes?

For a 768 height and far plane = 1000 it is giving a ~42 degrees FOV, which seems a bit low.

std::cout << "FOV = " << RadToDeg( FOVyForProjection( 768, 0.1f, 1000.f ) ) << std::endl;
// prints: FOV = 42.0174

1 Answer 1


I don't believe your second link's analysis works for a projection matrix FoV.

In that link, the angle of the field of view is centered on the middle of the lens. The 'camera' with a perspective matrix is actually located behind the near plane. So the distance between the near plane and the far plane being used as one component of the atan calculation will be incorrect (only off by 0.1 in this case, but still). The correct distance would be the distance between the far plane and the camera, which is just your value farClip.

Also, you don't need to calculate Field of View based on dimensions if you don't want to. You can also just use a desired field of view in your perspective matrix calculations. As long as your aspect ratio value is correct, the image will still look okay (for reasonable FoVs).


This guide shows how to create a perspective matrix that utilizes a custom FoV and also takes into account aspect ratio.

  • \$\begingroup\$ Good point, in the synthetic camera, the "eye" is behind the near plane. Thanks! \$\endgroup\$
    – glampert
    Sep 4, 2014 at 18:16

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .