How to set camera horizontal and vertical FOV
I have found that the dimension along which the FOV applies depends on the image aspect ratio.
Let us define the aspect ratio as the ratio of width / height, such that an aspect ratio larger than 1 means that we are in a landscape configuration.

if aspect ratio &gt; 1.0 
  FOV is along width.
else
  FOV is along height.


You can verify this by setting your image dimensions to, for example, X:2000; Y:1000, and Camera lens FOV:90°. Switch to ortho views and check the representation of the camera against the grid.
See the following screenshots:





With that in mind, you can use specific FOV values.
Remember that values going into and out of trigonometric functions have to be converted to and from radians.
I use vfov to mean the required vertical FOV and hfov to mean horizontal FOV.

A. To specify the vertical FOV:


If your image is portrait or square: 


just set the wanted value in the FOV field.

If your image is landscape: 


Use FOV = 2 * atan((0.5 * width) / (0.5 * height / tan(vfov/2)))



B. To specify the horizontal FOV:


If your image is landscape or square : 


just set the wanted value in the FOV field.

If your image is portrait:


Use FOV = 2 * atan((0.5 * height) / (0.5 * width / tan(hfov/2)))



(Note that you can simplify a bit if you compute the aspect ratio first)

Explanation:


We first find the focal length (in pixels) according to the required FOV, for example:

f = 0.5 * height / tan(vfov/2)
We use this to find the FOV along the other dimension.

hfov = 2 * atan((0.5 * width) / f)
thus,

hfov = 2 * atan((0.5 * width) / (0.5 * height / tan(vfov/2)))


Example:

We need a 90° vertical FOV on a landscape image of 2000×1000px.


vfov in radians = 90° * pi / 180° = 1.5707… rad.
hfov in radians = 2 * atan((0.5 * 2000) / (0.5 * 1000 / tan(1.5707/2))) = 2.2142… rad.
hfov in degrees = 2.2142 * 180° / pi = 126.87°.


Result: