计算FOVX(openGL)

Mik*_*012 4 opengl camera fieldofview perspective

使用openGL透视图时,我不太确定如何从fovy计算fovx.我在不同的地方阅读不同的东西,并且通过使用我找到的任何一种方法都没有得到正确的行为.那么有人可以告诉我,鉴于相机的性能和宽高比,如何计算相机的fovx?如果需要任何其他数据,那就让我知道我需要什么.非常感谢你提前!

Mac*_*cke 8

正确:

fieldOfViewX = 2 * atan(tan(fieldOfViewY * 0.5) * aspect)
Run Code Online (Sandbox Code Playgroud)

错了,特别是对于大方面,请参阅下面的@ gman的评论:

Aspect ratio === width/height
fovy ~= "height" 
==> fovx = fovy * aspect
Run Code Online (Sandbox Code Playgroud)

测试:

Fovy = 60 degs
Aspect = 4:3 ~= 1.33
Fovx = 60*1.33 = 80
80/60 = 4:3 (fovs match, yay)
Run Code Online (Sandbox Code Playgroud)

对于"合理的"fovs /方面,简单的方法是"合理地"接近事实,但如果你有极端的方面,你会得到fovx> 180度,这是你不想要的.

  • [这里是显示问题的示例](http://twgljs.org/examples/fov-checker.html)。“ fovx”是通过“ fieldOfViewX = 2 * atan(tan(fieldOfViewY * 0.5)* Aspect)”来计算的,其中“ aspect = width / height”。注意它与显示如何匹配。“ bad fovx”是使用您的方法计算的。使窗口短而宽,注意您的答案是错误的。 (3认同)