In THREE.js we construct a camera using the following function
const camera = new THREE.PerspectiveCamera(75, width / height, 0.1, 1000);
We know from optics that the field of view of a camera is related to the focal length by the following equation
FOV = arctan(d/2f)
where FOV
is the vertical FOV in degrees, d
is the height of the image plane in mm, and f
is the focal length of the camera in mm.
After reading the documentation on the matter, it seems as though d
is set by default to be 35mm / aspectRatio
.
We can express FOV
like this
FOV = arctan((35/(width/height))/2f) = arctan(filmHeight / 2f)
As a sanity check, I printed the following value, to see if I would get back the input FOV of 75
.
Math.atan(camera.getFilmHeight()/(2 * camera.getFocalLength())) * 180 / Math.PI;
But.. this value comes out to be 37.50000000000001
which is exactly half of the expected focal length of 75
.
So, I was wondering if I did the math wrong somewhere, or if I'm misinterpreting THREE.js's reported values.