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