189 8069 5689

ProjectionTransformations(投影变换)-创新互联

周一到周五,每天一篇,北京时间早上7点准时更新~

创新互联公司是一家集网站建设,中原企业网站建设,中原品牌网站建设,网站定制,中原网站建设报价,网络营销,网络优化,中原网站推广为一体的创新建站企业,帮助传统企业提升企业形象加强企业竞争力。可充分满足这一群体相比中小企业更为丰富、高端、多元的互联网需求。同时我们时刻保持专业、时尚、前沿,时刻以成就客户成长自我,坚持不断学习、思考、沉淀、净化自己,让我们为更多的企业打造出实用型网站。

The projection transformation is applied to your vertices after the model–view transformation. This projection actually defines the viewing volume and establishes clipping planes(投影变换发生在模型视口变换之后,这个矩阵定义了视锥体和剪裁平面们). The clipping planes are plane equations in 3D space that OpenGL uses to determine whether geometry can be seen by the viewer(剪裁平面定义在3D空间中,OpenGL使用这些剪裁平面去判断哪些几何物体是可以被看见的). More specifically, the projection transformation specifies how a finished scene (after all the modeling is done) is projected to the final image on the screen(更确切的说,投影变换决定了3D场景如何投影成为一张2D画面). You learn more about two types of projections—orthographic and perspective(你将会学到更多关于两种投影矩阵的东西-正交投影和透视投影). In an orthographic, or parallel, projection, all the polygons are drawn on screen with exactly the relative dimensions specified(在正交投影中、所有的多边形保持不变). Lines and polygons are mapped directly to the 2D screen using parallel lines, which means no matter how far away something is, it is still drawn the same size, just flattened against the screen(也就是说,无论物体离观察者多远,物体的大小都保持不变). This type of projection is typically used for rendering two-dimensional images such as the front, top, and side elevations in blueprints or two-dimensional graphics such as text or on-screen menus(这种模式尤其适合去做2D画面). A perspective projection shows scenes more as they appear in real life instead of as a blueprint(透视投影会产生近大远小的效果,就如同你生活中看场景的那样). The hallmark of perspective projections is foreshortening, which makes distant objects appear smaller than nearby objects of the same size. Lines in 3D space that might be parallel do not always appear parallel to the viewer(在透视投影下,在3D世界中的线原本是平行的,但是会看起来不平行). With a railroad track, for instance, the rails are parallel, but using perspective projection, they appear to converge at some distant point(这里就举了个例子说啥啥啥的本来是平行的,但在透视投影下不平行). The benefit of perspective projection is that you don’t have to figure out where lines converge or how much smaller distant objects are(透视投影的好处就是你不需要理会那些玩意到底有多大). All you need to do is specify the scene using the model–view transformations and then apply the perspective projection matrix(你所需要做的就是,先试用模型视口矩阵给物体变换一下,然后用透视矩阵去处理,线性代数会帮你处理好所有的问题). Linear algebra works all the magic for you. Figure 4.12 compares orthographic and perspective projections on two different scenes(图4.12展示了正交和透视投影下的两个不同场景的效果). As you can see in the orthographic projection shown on the left, the cubes do not appear to change in size as they move farther from the viewer(如你所见,左边是正交投影,当立方体越来越远的时候,大小不变). However, in the perspective projection shown on the right, the cubes get smaller and smaller as they get farther from the viewer(然而在透视投影下,距离越远,看起来越小)

Projection Transformations(投影变换)
Orthographic projections are used most often for 2D drawing purposes where you want an exact correspondence between pixels and drawing units. You might use them for a schematic layout, text, or perhaps a 2D graphing application. You also can use an orthographic projection for 3D renderings when the depth of the rendering has a very small depth in comparison to the distance from the viewpoint(通常来说,正交投影适合做2D的应用,有时候也会拿去做一些深度变化不是很明显的3D场景渲染). Perspective projections are used for rendering scenes that contain wide-open spaces or objects that need to have foreshortening applied. For the most part, perspective projections are typical for 3D graphics. In fact, looking at a 3D object with an orthographic projection can be somewhat unsettling.(透视投影则是用来做3D产品的,这种产品明显的特点就是,需要有近大远小的效果,实际上如果你用正交投影去显示3D场景,你会觉得很蛋疼)

Perspective Matrices(透视矩阵)

Once your vertices are in view space, we need to get them into clip space, which we do by applying our projection matrix, which may represent a perspective or orthographic projection (or some other projection)(当你当你的顶点数据在视口空间下了之后,你需要把他们玩到剪裁坐标系里去,在这里进行投影变换). A commonly used perspective matrix is a frustum matrix. A frustum matrix is a projection matrix that produces a perspective projection such that clip space takes the shape of a rectangular frustum, which is a truncated rectangular pyramid. Its parameters are the distance to the near and far planes and the world-space coordinate of the left, right, top, and bottom clipping planes. A frustrum matrix takes the following form:(一个常见的透视矩阵就是视锥体矩阵,视锥体矩阵是一个透视矩阵,你需要指定左右上下近剪裁面远剪裁面来定义这个矩阵,它呈现的形状则是倒金字塔形,下面展示了产生视锥体的函数)
Projection Transformations(投影变换)
static inline mat4 frustum(float left,
float right,
float bottom,
float top,
float n,
float f) { ... }
Another common method for constructing a perspective matrix is to directly specify a field of view as an angle (in degrees, perhaps), an aspect ratio (generally derived by dividing the window’s width by its height), and the view-space positions of the near and far planes. This is somewhat simpler to specify, and produces only symmetric frustra. However, this is almost always what you’ll want. The vmath function to do this is vmath::perspective:(另一种指定投影矩阵的方式就是直接指定视口的可见角度、长宽比、近剪裁面远剪裁面。我们的教学体系中使用的就是第二种方式,同时数学课中也推导了这些矩阵的来历。vmath的相关接口如下)

static inline mat4 perspective(float fovy / in degrees/,
float aspect,
float n,
float f) { ... }
Orthographic Matrices(正交矩阵)

If you wish to use an orthographic projection for your scene, then you can construct a (somewhat simpler) orthographic projection matrix(如果你想对你的场景使用正交变换,那么你可以构建一个正交投影矩阵). An orthographic projection matrix is simply a scaling matrix that linearly maps view-space coordinates into clip-space coordinates(一个正交投影矩阵就是线性的将视口空间下的玩意映射到剪裁空间里去). The parameters to construct the orthographic projection matrix are the left, right, top, and bottom coordinates in view space of the bounds of the scene, and the position of the near and far planes. The form of the matrix is(构建这样的矩阵的参数是:左右上下、近剪裁面,远剪裁面,矩阵的形式如下图所示)
Projection Transformations(投影变换)
Again, there’s a vmath function to construct this matrix for you, vmath::ortho:(vmath库中创建正交矩阵的接口如下:)

static inline mat4 ortho(float left,
float right,
float bottom,
float top,
float near,
float far) { ... }
本日的翻译就到这里,明天见,拜拜~~

第一时间获取最新桥段,请关注东汉书院以及图形之心公众号

东汉书院,等你来玩哦

另外有需要云服务器可以了解下创新互联cdcxhl.cn,海内外云服务器15元起步,三天无理由+7*72小时售后在线,公司持有idc许可证,提供“云服务器、裸金属服务器、高防服务器、香港服务器、美国服务器、虚拟主机、免备案服务器”等云主机租用服务以及企业上云的综合解决方案,具有“安全稳定、简单易用、服务可用性高、性价比高”等特点与优势,专为企业上云打造定制,能够满足用户丰富、多元化的应用场景需求。


网站题目:ProjectionTransformations(投影变换)-创新互联
标题路径:http://jkwzsj.com/article/cejiss.html

其他资讯