Graphics.FOVConversion - lordmundi/wikidoctest GitHub Wiki

FOV Conversion

In DOUG, the vertical field of view (VFOV) and horizontal field of view (HFOV) are related by the aspect ratio.

The only caveat is that the aspect ratio scales the tangent of the half angle, and not the angle itself.

The formula is:

{ VFOV } = 2 \times \tan^{-1}{\displaystyle \left(\tan{\left(HFOV \over 2\right)} \over aspectratio \right)}

NOTE: Keep in mind that the cctv plugin (as of now) assumes a 1.3333 aspect ratio.

There is also the notion of the zoom factor in DOUG. The zoom factor is essentially the ratio of the tangent of the reference VFOV for the viewport (known as the VFOV_ref and defined in the config file) to the tangent of the actual VFOV of the camera. Like above though, it is the ratio of the tangent of the half-angle. The VFOV_ref is almost always set to 40.9 in most config files.

\huge zoom factor = \frac{\tan \left ( \frac{VFOV_{ref}}{2.0}\right )}{\tan \left ( \frac{VFOV}{2.0}\right )}

If you are working with HFOV, then you would multiply the numerator with the aspect ratio of the viewport (also specified in the config file) and use HFOV in the denominator. Then the equation becomes:

\huge zoom factor = \frac{\tan \left ( \frac{VFOV_{ref}}{2.0}\right ) \times aspectratio}{\tan \left ( \frac{HFOV}{2.0}\right )}

Why do we do this? Well, it has to do with the window dimensions and how that affects field of view (adjusting the window vertically maintains the HFOV in accordance with the specified aspect ratio of the viewport). Using the above equation, and knowing your viewport resolution, you should be able to calculate the zoom factor you need to obtain a specified HFOV or VFOV.