投影变换Projection Transformation学习笔记 您所在的位置:网站首页 transformation和transfer 投影变换Projection Transformation学习笔记

投影变换Projection Transformation学习笔记

2023-09-14 02:42| 来源: 网络整理| 查看: 265

概述

投影 :数学术语,指图形的影子投到一个面或一条线上。 在计算机图形学中,投影变换是把3D几何体转换成一种可作为二维图像渲染的方法。其中最常用的两种投影方式为正交投影和透视投影。

正交投影(Orthographics Projection)

the view volume is an axis-aligned box, and we’ll name the coordinates of its sides so that the view volume is [l, r] × [b, t] × [f, n] shown in Figure 7.4. ——《Fundamentals of Computer Graphics 4th》P142

Figure 7.5

书中认为,当我们将摄像机固定为坐标原点、看向-z轴方向并以y轴为上方时,令视图体是一个轴向对齐的框,我们将命名它的边的坐标为[l, r] x [b, t] x [f, n](其中0>n>f),就像Figure7.5中展示的那样(原书中为7.4) 将其转换为每个边的边长都为2、中心点在原点的正方形,于是书中直接得出了一个正交变换矩阵(一个显然我要推一下才能看懂,是我太菜了)。 M_orth

透视投影(Perspective Projection)(难点)

The key property of perspective is that the size of an object on the screen is proportional to 1/z for an eye at the origin looking up the negative z-axis. This can be expressed more precisely in an equation for the geometry in Figure 7.8: where y is the distance of the point along the y-axis, and ys is where the point should be drawn on the screen.

Figure7.8 就像公式中那样,在此变换中出现了输入向量z在分母上的情况,所以不能使用仿射变换做到。 这里继续引入齐次坐标[x, y, z, w],并允许w不为1,即[x, y, z, w]代表点[x/w, y/w, z/w]。 然后我就可以认为一个点p = ax + by + cz + d。这样我们就可以处理向量在分母上的情况了。 进而可以得到: 第一层公式 所以我们想要找到一个矩阵能够做到: 目标矩阵 我们希望得到透视变换后的坐标[x1, y1, z1, w1] = M(x, y, z, 1) = [nx/z, ny/z, unknown, 1] = [nx, ny, still unknown, z] 得到M的前两行为{ [n, 0, 0, 0], [0, n, 0, 0] }。 为了避免矩阵中含有输入变量,这里对第四行进行解得[0, 0, 1, 0]。 又易得第三行与x和y无关,得到M={ [n, 0, 0, 0], [0, n, 0, 0], [0, 0, A, B], [0, 0, 1, 0] } 这里的解法很微妙 取两个关键点,[0, 0, n, 1]和[0, 0, f, 1],他们进行变换后的坐标应该为[0, 0, n^2, n]和[0, 0, f^2, f]。 由此得到二元一次方程组 { An + B = n^2, Af + B = f^2 } 解得A=n+f,B=-nf 由此可得最终M={ [n, 0, 0, 0], [0, n, 0, 0], [0, 0, n+f, -nf], [0, 0, 1, 0] }

通过透视变换我们获得了一个长方体,下面就可以进行正交变换了。 有Mper = Morth·P Mper 呼,常用的变换完成了。



【本文地址】

公司简介

联系我们

今日新闻

    推荐新闻

      专题文章
        CopyRight 2018-2019 实验室设备网 版权所有