如何计算相机的 z 距离以在 3D 空间中以 100% 的原始比例查看图像 [英] How to calculate the z-distance of a camera to view an image at 100% of its original scale in a 3D space

查看:12
本文介绍了如何计算相机的 z 距离以在 3D 空间中以 100% 的原始比例查看图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何计算相机与 3D 空间中的对象(在本例中为图像)的距离,以使图像处于其原始像素宽度.

How can one calculate the camera distance from an object in 3D space (an image in this case) such that the image is at its original pixel width.

考虑到相机的纵横比、fov 和图像的原始宽度/高度(以像素为单位),我是否认为这是可能的?

Am I right in assuming that this is possible given the aspect ratio of the camera, fov, and the original width/height of the image in pixels?

(如果相关,我在这个特定实例中使用 THREE.js).

(In case it is relevant, I am using THREE.js in this particular instance).

感谢任何可以帮助或引导我走向正确方向的人!

Thanks to anyone who can help or lead me in the right direction!

推荐答案

感谢大家的投入!

在进行了一些挖掘,然后弄清楚这一切如何适合我试图用 THREE.js 解决的确切问题后,这是我在 JavaScript 中想出的答案,作为目标 Z 距离,用于以原始方式显示事物规模:

After doing some digging and then working out how this all fits into the exact problem I was trying to solve with THREE.js, this was the answer I came up with in JavaScript as the target Z distance for displaying things at their original scale:

var vFOV = this.camera.fov * (Math.PI / 180), // convert VERTICAL fov to radians

var targetZ = window.innerHeight / (2 * Math.tan(vFOV / 2) );

我试图找出将哪个标记为答案,但我将所有这些都合并到了这个解决方案中.

I was trying to figure out which one to mark as the answer but I kind of combined all of them into this solution.

这篇关于如何计算相机的 z 距离以在 3D 空间中以 100% 的原始比例查看图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆