如何知道单位的飞机尺寸? [英] How to know the plane size in units?

查看:119
本文介绍了如何知道单位的飞机尺寸?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

好吧,我不想用不同的宽度和高度来描绘迷宫.我正在以单位绘制它们,而我的问题是,如何才能以平面获得可见的尺寸,我会知道我必须在迷宫中绘制多深才能完全可见它.对于透视图,我使用":: gluPerspective(45.0f,(GLfloat)width/(GLfloat)height,1.0f,100.0f);"

Well the thing is, that I wan't to picture mazes with a different width and height. I'm drawing them in units and my question is, how can I get the plane viewable dimensions in units that I would know how deep inside the screen I would have to draw my maze in order it would be fully seeable. For perspective view I use "::gluPerspective(45.0f, (GLfloat)width / (GLfloat)height, 1.0f, 100.0f);"

例如,如何获取以OpenGL为单位的近平面尺寸(宽度和高度)或远平面或这些平面之间的任何平面.如果要绘制完全可见的图像,我需要知道OpenGL单位中的平面尺寸,或者还有另一种方法吗?

For example how I get the near plane dimensions(width and height) in OpenGL units or the far plane or any plane between those planes. If I want to picture something entirely seeable I need to know the plane dimensions in OpenGL units or is there another way?

推荐答案

一些三角函数将告诉您:h_near = 2*near*tan(fovy/2)和到目前为止的相同:h_far = 2*far*tan(fovy/2)

A bit of trigonometry will tell you that: h_near = 2*near*tan(fovy/2) and the same for far: h_far = 2*far*tan(fovy/2)

然后,比率将为您提供宽度.

Then, the ratio will give you the width.

对于证明",只需考虑由视线,渲染平面的垂直方向和背面形成的直角三角形.视线的长度为nearfar(视情况而定),眼睛位置的角度为fovy/2(即视角的一半),并且平面上的垂直方向为h_near/2h_far/2 ,因为我们仅到达飞机的中途.然后,直角三角形上的角度的切线等于远侧除以近侧...

For the "proof", just consider the right-angled triangle formed by the line of view, the vertical of the plane of rendering and back. The length of the line of view is near or far (depending), the angle at the eye position is fovy/2 (i.e. half the view angle) and the vertical on the plane is h_near/2 or h_far/2, as we only get half-way to the plane. Then, the tangent of the angle on a right-angled triangle is equal to the far-side divided by the near-side ...

这篇关于如何知道单位的飞机尺寸?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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