When working with THREE.js, one of the fundamental aspects is constructing a camera using a specific function:
const camera = new THREE.PerspectiveCamera(75, width / height, 0.1, 1000);
An interesting aspect to consider regarding cameras is the relationship between field of view and focal length in optics, defined by this equation:
FOV = arctan(d/2f)
Here, FOV
represents the vertical FOV in degrees, d
corresponds to the image plane's height in mm, and f
denotes the camera's focal length in mm.
The documentation on this subject speaks about how d
is automatically set as 35mm / aspectRatio
.
This calculation allows us to express FOV
differently:
FOV = arctan((35/(width/height))/2f) = arctan(filmHeight / 2f)
To verify accuracy, I checked the following value to see if it matched the input FOV
of 75
:
Math.atan(camera.getFilmHeight()/(2 * camera.getFocalLength())) * 180 / Math.PI;
Surprisingly, the result was 37.50000000000001
,
which stands at precisely half of the projected focal length of 75
.
At this point, I pondered whether I made an error during my calculations or misunderstood the values provided by THREE.js.