简体   繁体   English

THREE.js PerspectiveCamera focusLength 关闭两倍,与 FOV 不一致

[英]THREE.js PerspectiveCamera focalLength off by a factor of two, inconsistent with FOV

In THREE.js we construct a camera using the following function在 THREE.js 中,我们使用以下函数构建了一个相机

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.其中FOV是以度为单位的垂直 FOV, d是图像平面的高度,单位为 mm, f是相机的焦距,单位为 mm。

After reading the documentation on the matter, it seems as though d is set by default to be 35mm / aspectRatio .阅读有关此事的文档后,似乎d默认设置为35mm / aspectRatio

We can express FOV like this我们可以这样表达FOV

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 .作为健全性检查,我打印了以下值,以查看是否能取回75的输入 FOV。

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

But.. this value comes out to be 37.50000000000001但是..这个值是37.50000000000001

which is exactly half of the expected focal length of 75 .这正好是预期焦距75一半。

So, I was wondering if I did the math wrong somewhere, or if I'm misinterpreting THREE.js's reported values.所以,我想知道我是否在某个地方做错了数学,或者我是否误解了 THREE.js 报告的值。

The .fov angle is the .fov角度是

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的一半:

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM