如何计算的z距离的照相机的在其原有的规模为100%在一个三维空间中查看图像 [英] How to calculate the z-distance of a camera to view an image at 100% of its original scale in a 3D space

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

问题描述

1如何计算从在三维空间中(在此情况下的图像)的对象的摄像机的距离,使得该图像是在它的原始像素的宽度。

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!

推荐答案

谢谢大家对所有的输入!

Thanks everyone for all the input!

在做一些挖掘,然后制定出这一切是如何融入确切的问题,我试图解决与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距离的照相机的在其原有的规模为100%在一个三维空间中查看图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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