最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - THREE.js PerspectiveCamera focalLength off by a factor of two, inconsistent with FOV - Stack Overflow

programmeradmin4浏览0评论

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 es 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.

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 es 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.

Share Improve this question edited Apr 15, 2020 at 14:02 Rabbid76 211k30 gold badges158 silver badges200 bronze badges asked Dec 21, 2018 at 8:50 CarpetfizzCarpetfizz 9,19923 gold badges95 silver badges155 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 10

The .fov angle is the

Camera frustum vertical field of view, from bottom to top of view, in degrees.

But what you calculate is, the angle of the center of the view to the top:

Math.atan( (camera.getFilmHeight()/2) / camera.getFocalLength())) * 180 / Math.PI;

this is indeed the half of .fov:

fov = 2 * Math.atan( (camera.getFilmHeight()/2) / camera.getFocalLength())) * 180 / Math.PI;

与本文相关的文章

发布评论

评论列表(0)

  1. 暂无评论