【问题标题】:THREE.js PerspectiveCamera focalLength off by a factor of two, inconsistent with FOVTHREE.js PerspectiveCamera focusLength 相差两倍,与 FOV 不一致
【发布时间】:2019-05-21 17:50:42
【问题描述】:

在 THREE.js 中,我们使用以下函数构造一个摄像头

const camera = new THREE.PerspectiveCamera(75, width / height, 0.1, 1000);

我们从光学中知道,相机的视场与焦距有关,公式如下:

FOV = arctan(d/2f)

其中FOV 是以度为单位的垂直 FOV,d 是以毫米为单位的图像平面高度,f 是以毫米为单位的相机焦距。

在阅读the documentation关于此事后,似乎d默认设置为35mm / aspectRatio

我们可以这样表达FOV

FOV = arctan((35/(width/height))/2f) = arctan(filmHeight / 2f)

作为健全性检查,我打印了以下值,以查看是否能取回 75 的输入 FOV。

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

但是..这个值是37.50000000000001

正好是75 预期焦距的一半。

所以,我想知道我是否在某个地方做错了数学,或者我是否误解了 THREE.js 的报告值。

【问题讨论】:

    标签: javascript three.js perspectivecamera


    【解决方案1】:

    .fov 角度是

    相机平截头体垂直视野,从底部到顶部,以度为单位。

    但你计算的是,视图中心到顶部的角度:

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

    这确实是.fov的一半:

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

    【讨论】:

      猜你喜欢
      • 2017-10-17
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-01-14
      • 2019-02-11
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多