注:教材原第6章编写者在6.3.3透视投影章节部分有一些地方介绍不清,另外在推导透视投影时所构建的坐标系也并非最佳方式,因此有可能会造成一些理解困难,在此表示抱歉。关于透视投影的推导及有关知识,可以在本博客上下载我本人的教学课件来学习了解。我构建的坐标系目前应该比较合理,同时也会得出比较漂亮的透视结论😄。有问题欢迎邮件联系我:wpxu08@gmail.com
页码 | 行或位置 | 原内容 | 更正为 | 备注 |
---|---|---|---|---|
38 | 9 | (1MB) | (128KB) | |
41 | 16 | k = Δ x / Δ y k=\Delta x/\Delta y k=Δx/Δy | k = Δ y / Δ x k=\Delta y/\Delta x k=Δy/Δx | |
43 | 9 | d ≤ 0 d \leq 0 d≤0 | d ≥ 0 d \geq 0 d≥0 | |
46 | 6 | s − t = s Δ x Δ y ( x i + 1 ) + 2 b + 2 y i − 1 s-t = s \frac{\Delta x}{\Delta y}(x_i+1)+2b+2y_i-1 s−t=sΔyΔx(xi+1)+2b+2yi−1 | s − t = s Δ x Δ y ( x i + 1 ) + 2 b − 2 y i − 1 s-t = s \frac{\Delta x}{\Delta y}(x_i+1)+2b -2y_i-1 s−t=sΔyΔx(xi+1)+2b−2yi−1 | |
46 | 倒数第4行 | − 1 ≤ 1 ≤ 0 -1\leq1\leq0 −1≤1≤0 | 0 ≤ k ≤ 1 0\leq k\leq 1 0≤k≤1 | |
47 | 26 | int curx = x1; | int curx = x1 + 1; | |
48 | 12 | b = x 0 − x 1 b=x_0-x_1 b=x0−x1 | b = x 1 − x 0 b=x_1-x_0 b=x1−x0 | |
51 | 19 | 令 T T T点的坐标为 ( x i , y i ) (x_i, y_i) (xi,yi) | 令 P P P点的坐标为 ( x i , y i ) (x_i, y_i) (xi,yi) | |
52 | 10,12 | y i − 1 y_{i-1} yi−1 | y i + 1 y_{i+1} yi+1 | |
52 | 倒数第3行 | Cirpot(x0, y0, x, y) | Cirpot(x0, y0, x, y, color) | |
53 | 9 | Cirpot(x0, y0, x, y) | Cirpot(x0, y0, x, y, color) | |
57 | 7 | FloodFill | FloodFill4 | |
57 | 13-16 | FloodFill4(…, newcolor) | FloodFill4(…, newcolor, boundaryColor) | |
58-59 | 58页倒数第2行~59页第11行 | 见教材 | 从点P向任意方向发出一条射线,若该射线与多边形交点的个数为奇数,则P位于多边形内;若为偶数,则P位于多边形外部。当射线与多边形边界点的交点是多边形顶点时(该交点称为奇点,如图3-13的 P 3 P_3 P3, P 4 P_4 P4, P 5 P_5 P5和 P 6 P_6 P6情况),如果把每一个奇点简单地计为一个交点,则交点个数为偶数时P点可能在内部,如图3-13中的 P 4 P_4 P4情况。但若将每一个奇点都简单地计为两个交点,同样会导致错误的结果,如图3-13中的 P 3 P_3 P3和 P 5 P_5 P5情况。因此,必须按不同情况区别对待。一般来说,多边形的顶点可分为两类:极值点和非极值点。如果顶点相邻的两边在射线的同侧时,则称该顶点为极值点(如图3-13中的 Q 0 Q_0 Q0和 Q 1 Q_1 Q1);否则称该顶点为非极值点(如图3-13中的 Q 2 Q_2 Q2)。为了保证射线法判别结果的正确性,奇点交点的计数可以根据上述分类来采用不同的方式。当奇点是多边形的极值点时,交点按照两个交点计算,否则,按一个交点计算,如图3.13所示。 | |
59 | 图3-13 | 见教材 | ||
60 | 图3.16 | |||
65 | 倒数第4行 | 图3.22 | 图3.23 | |
65 | 倒数第3行 | y i + m / 2 y_i+m/2 yi+m/2 | y i − i n t ( y i ) + m / 2 y_i-int(y_i)+m/2 yi−int(yi)+m/2 | |
73 | 6 | y ′ = r s i n ( ϕ + θ ) = r c o s ϕ s i n θ − r s i n ϕ c o s θ y'=rsin(\phi+\theta)=rcos \phi sin \theta - rsin \phi cos \theta y′=rsin(ϕ+θ)=rcosϕsinθ−rsinϕcosθ | y ′ = r s i n ( ϕ + θ ) = r c o s ϕ s i n θ + r s i n ϕ c o s θ y'=rsin(\phi+\theta)=rcos \phi sin \theta + rsin \phi cos \theta y′=rsin(ϕ+θ)=rcosϕsinθ+rsinϕcosθ | |
75 | 8 | 相对于y轴的反射 | 相对于x轴的反射 | |
82/87 | 式(4.40/57) | [ c o s θ − s i n θ 0 s i n θ c o s θ 0 0 0 1 ] \begin{bmatrix} cos\theta & \mathbf{-sin\theta} & 0 \\ \mathbf{sin\theta} & cos\theta & 0 \\ 0 & 0 & 1 \\ \end{bmatrix} ⎣⎡cosθsinθ0−sinθcosθ0001⎦⎤ | [ c o s θ s i n θ 0 − s i n θ c o s θ 0 0 0 1 ] \begin{bmatrix} cos\theta & \mathbf{sin\theta} & 0 \\ \mathbf{-sin\theta} & cos\theta & 0 \\ 0 & 0 & 1 \\ \end{bmatrix} ⎣⎡cosθ−sinθ0sinθcosθ0001⎦⎤ | |
84 | 式(4.51) | y r ( 1 − c o s θ ) + x r s i n θ y_r(1-cos\theta)+x_rsin\theta yr(1−cosθ)+xrsinθ | y r ( 1 − c o s θ ) − x r s i n θ y_r(1-cos\theta)-x_rsin\theta yr(1−cosθ)−xrsinθ | |
94 | 图4.30 | |||
117 | 2 | T = R ( θ ) T ( − x 0 , − y 0 ) = [ c o s θ s i n θ 0 − s i n θ c o s θ 0 0 0 1 ] [ 1 0 − x 0 0 1 − y 0 0 0 1 ] T=R(\theta)T(-x_0, -y_0) =\begin{bmatrix} cos\theta & \mathbf{sin\theta} & 0 \\ \mathbf{-sin\theta} & cos\theta & 0 \\ 0 & 0 & 1 \\ \end{bmatrix} \begin{bmatrix} 1 & 0 & -x_0 \\0 & 1 & -y_0 \\0 & 0 & 1 \end{bmatrix} T=R(θ)T(−x0,−y0)=⎣⎡cosθ−sinθ0sinθcosθ0001⎦⎤⎣⎡100010−x0−y01⎦⎤ | T = R ( θ ) T ( − x 0 , − y 0 ) = [ c o s θ − s i n θ 0 s i n θ c o s θ 0 0 0 1 ] [ 1 0 − x 0 0 1 − y 0 0 0 1 ] T=R(\theta)T(-x_0, -y_0) = \begin{bmatrix} cos\theta & -sin\theta & 0 \\sin\theta & cos\theta & 0 \\ 0 & 0 & 1 \end{bmatrix} \begin{bmatrix} 1 & 0 & -x_0 \\0 & 1 & -y_0 \\0 & 0 & 1 \end{bmatrix} T=R(θ)T(−x0,−y0)=⎣⎡cosθsinθ0−sinθcosθ0001⎦⎤⎣⎡100010−x0−y01⎦⎤ | |
122 | 15 | t 1 ′ ′ = ( x R − x 1 ) / d x t_1^{''}=(x_R-x_1)/dx t1′′=(xR−x1)/dx | t 1 ′ ′ = ( y B − y 1 ) / d y t_1^{''}=(y_B-y_1)/dy t1′′=(yB−y1)/dy | |
130 | 24 | glLoadIdentity() | 应移至void display(void)中的第1个glColor3f(0.0,0.0,1.0)后 | 参考5.5 Opengl编程实例-红蓝三角形 |
131 | 1 | |||
131 | 图5.17后 | 无 | 增加思考内容:“思考:教材中原代码中根据所给三角形顶点坐标,三角形应为一个正角形,为何显示时不是正角形呢?同时,在旋转后的三角形也发生了变形,请分析原因,并给出修改建议。提示:请从"glViewport()"函数入手。” | |
135 | (6.2) | u = V × n ∣ N ∣ = ( u x , u y , u z ) u=\frac{V \times n}{\mid N \mid} = (u_x, u_y, u_z) u=∣N∣V×n=(ux,uy,uz) | u = V × n ∣ V × n ∣ = ( u x , u y , u z ) u=\frac{V \times n}{\mid V \times n \mid} = (u_x, u_y, u_z) u=∣V×n∣V×n=(ux,uy,uz) | |
137 | 9 | O点在xoy平面内的投影为… | O s O_s Os点在xoy平面内的投影为… | |
151 | (6.29) | [ x p y p 0 1 ] = [ 1 0 0 0 0 1 0 0 0 0 0 0 0 0 0 1 ] [ 1 0 0 0 0 1 0 0 0 0 1 0 0 0 1 d 1 ] [ x s y s z s 1 ] = [ x s y s 0 1 + z s d ] \begin{bmatrix}x_p \\ y_p \\ 0 \\ 1 \end{bmatrix} =\begin{bmatrix}1 & 0 & 0 & 0\\ 0 & 1 & 0 & 0 \\ 0 & 0 & 0 & 0 \\ 0 & 0 & 0 & 1\end{bmatrix} \begin{bmatrix} 1 & 0 & 0 & 0\\ 0 & 1 & 0 & 0 \\ 0 & 0 & 1 & 0 \\ 0 & 0 & \frac{1}{d} & \mathbf{ 1} \end{bmatrix} \begin{bmatrix} x_s \\ y_s \\ z_s \\ 1 \end{bmatrix} = \begin{bmatrix} x_s \\ y_s \\ 0 \\ \mathbf{1+ \frac{z_s}{d}} \end{bmatrix} ⎣⎢⎢⎡xpyp01⎦⎥⎥⎤=⎣⎢⎢⎡1000010000000001⎦⎥⎥⎤⎣⎢⎢⎡10000100001d10001⎦⎥⎥⎤⎣⎢⎢⎡xsyszs1⎦⎥⎥⎤=⎣⎢⎢⎡xsys01+dzs⎦⎥⎥⎤ | [ x p y p 0 1 ] = [ 1 0 0 0 0 1 0 0 0 0 0 0 0 0 0 1 ] [ 1 0 0 0 0 1 0 0 0 0 1 0 0 0 1 d 0 ] [ x s y s z s 1 ] = [ x s y s 0 z s d ] \begin{bmatrix} x_p \\ y_p \\ 0 \\ 1 \end{bmatrix} =\begin{bmatrix}1 & 0 & 0 & 0\\ 0 & 1 & 0 & 0 \\0 & 0 & 0 & 0 \\0 & 0 & 0 & 1\end{bmatrix} \begin{bmatrix} 1 & 0 & 0 & 0\\ 0 & 1 & 0 & 0 \\ 0 & 0 & 1 & 0 \\ 0 & 0 & \frac{1}{d} & \mathbf{0}\end{bmatrix} \begin{bmatrix} x_s \\ y_s \\ z_s \\ 1 \end{bmatrix} = \begin{bmatrix} x_s \\ y_s \\ 0 \\ \mathbf{ \frac{z_s}{d} } \end{bmatrix} ⎣⎢⎢⎡xpyp01⎦⎥⎥⎤=⎣⎢⎢⎡1000010000000001⎦⎥⎥⎤⎣⎢⎢⎡10000100001d10000⎦⎥⎥⎤⎣⎢⎢⎡xsyszs1⎦⎥⎥⎤=⎣⎢⎢⎡xsys0dzs⎦⎥⎥⎤ | |
151 | (6.31) | [ 1 0 0 0 0 1 0 0 0 0 1 0 0 0 r 1 ] \begin{bmatrix}1 & 0 & 0 & 0\\ 0 & 1 & 0 & 0 \\ 0 & 0 & 1 & 0 \\ 0 & 0 & r & \mathbf{1}\end{bmatrix} ⎣⎢⎢⎡10000100001r0001⎦⎥⎥⎤ | [ 1 0 0 0 0 1 0 0 0 0 1 0 0 0 r 0 ] \begin{bmatrix} 1 & 0 & 0 & 0\\ 0 & 1 & 0 & 0 \\ 0 & 0 & 1 & 0 \\ 0 & 0 & r & \mathbf{0}\end{bmatrix} ⎣⎢⎢⎡10000100001r0000⎦⎥⎥⎤ | |
151 | (6.33) | [ 1 0 0 0 0 1 0 0 0 0 1 0 p 0 0 1 ] \begin{bmatrix}1 & 0 & 0 & 0\\ 0 & 1 & 0 & 0 \\0 & 0 & 1 & 0 \\ p & 0 & 0 & \mathbf{1}\end{bmatrix} ⎣⎢⎢⎡100p010000100001⎦⎥⎥⎤ | [ 1 0 0 0 0 1 0 0 0 0 1 0 p 0 0 0 ] \begin{bmatrix}1 & 0 & 0 & 0 \\ 0 & 1 & 0 & 0 \\ 0 & 0 & 1 & 0 \\ p & 0 & 0 & \mathbf{0 }\end{bmatrix} ⎣⎢⎢⎡100p010000100000⎦⎥⎥⎤ | |
151 | (6.34) | [ 1 0 0 0 0 1 0 0 0 0 1 0 0 q 0 1 ] \begin{bmatrix} 1 & 0 & 0 & 0\\ 0 & 1 & 0 & 0 \\ 0 & 0 & 1 & 0 \\ 0 & q & 0 & \mathbf{1}\end{bmatrix} ⎣⎢⎢⎡1000010q00100001⎦⎥⎥⎤ | [ 1 0 0 0 0 1 0 0 0 0 1 0 0 q 0 0 ] \begin{bmatrix} 1 & 0 & 0 & 0\\ 0 & 1 & 0 & 0 \\ 0 & 0 & 1 & 0 \\ 0 & q & 0 & \mathbf{0}\end{bmatrix} ⎣⎢⎢⎡1000010q00100000⎦⎥⎥⎤ | |
152 | (6.35) | |||
152 | (6.35) | |||
152 | 12 | 线性关系 | 非线性关系 | |
152 | (6.37) | a = − ( z f a r + z n e a r ) z n e a r z f a r − z n e a r a=\frac{-(z_{far}+z_{near})z_{near}}{z_{far}-z_{near}} a=zfar−znear−(zfar+znear)znear | a = z f a r + z n e a r z n e a r ( z f a r − z n e a r ) a=\frac{z_{far}+z_{near}}{z_{near}(z_{far}-z_{near})} a=znear(zfar−znear)zfar+znear | |
195 | (7.29) | . . ∑ i = 0 n . . . ..\sum_{i=0}^{n}... ..i=0∑n... | . . . ∑ l = 0 n . . . ...\sum_{l=0}^{n}... ...l=0∑n... | |
195 | (7.30) 上方 | 二次B样条曲线中,n=2, l = 1, 2, 3… | 二次B样条曲线中,n=2, l = 0, 1, 2, 当i=0时… | |
195 | (7.30) | . . ∑ i = 0 2 . . . ..\sum_{i=0}^{2}... ..i=0∑2... | . . . ∑ l = 0 2 . . . ...\sum_{l=0}^{2}... ...l=0∑2... | |
196 | 倒数第2行 | . . . + 2 t 2 + . . . ...+2t^2+... ...+2t2+... | . . . + 3 t 2 + . . . ...+3t^2+... ...+3t2+... | |
198 | 第3行 | P ′ ( 1 ) = . . . P'(1)=... P′(1)=... | Q ′ ( 1 ) = . . . Q'(1)=... Q′(1)=... | |
205 | 第2行 | [ − 1 3 − 3 1 3 − 6 3 0 − 3 3 0 0 1 0 0 0 ] \begin{bmatrix} -1 & 3 & -3 & 1\\ 3 & -6 & 3 & 0 \\ -3 & 3 & 0 & 0 \\ 1 & 0 & 0 & 0\end{bmatrix} ⎣⎢⎢⎡−13−313−630−33001000⎦⎥⎥⎤ | [ − 1 3 − 3 1 3 − 6 3 0 − 3 0 3 0 1 4 1 0 ] \begin{bmatrix} -1 & 3 & -3 & 1\\ 3 & -6 & 3 & 0 \\ -3 & 0 & 3 & 0 \\ 1 & 4 & 1 & 0\end{bmatrix} ⎣⎢⎢⎡−13−313−604−33311000⎦⎥⎥⎤ | |
224 | 2 | 对于右手坐标系 | 对于OpenGL所采用的左手坐标系 | 烟台大学韩明峰指正 |
图8.17 | ||||
8 | 深度缓冲器所有单元均置为最小 z值 | 深度缓冲器所有单元均置为最大 z值 | 为保持与图8.17一致而修改,原内容也没错,下同 | |
11 | 若z > ZB(x, y),则ZB(x, y)=z | 若z < ZB(x, y),则ZB(x, y)=z | ||
20 | ZB(x,y)单元置为最小值 | ZB(x,y)单元置为最大值 | ||
26 | if(z(x,y) > ZB(x,y)) | if(z(x,y) < ZB(x,y)) | ||
242 | (8.23) | I s = 1 x b − x a [ I b ( x b − x s ) + I a ( x s − x a ) ] I_{s}=\frac{1}{x_{b}-x_{a}}[I_{b}(x_{b}-x_{s})+I_{a}(x_{s}-x_{a})] Is=xb−xa1[Ib(xb−xs)+Ia(xs−xa)] | I s = 1 x b − x a [ I a ( x b − x s ) + I b ( x s − x a ) ] I_{s}=\frac{1}{x_{b}-x_{a}}[I_{a}(x_{b}-x_{s})+I_{b}(x_{s}-x_{a})] Is=xb−xa1[Ia(xb−xs)+Ib(xs−xa)] |
附录B 模拟试题及答案
页码 | 位置 | 原内容 | 更正 | 备注 |
---|---|---|---|---|
337 | 图B.1 | |||
340 | 模2试题,一.单选题,第6题 | T = [ 2 0 0 0 1 0 1 1 1 ] T= \left[ \begin{matrix} 2 & 0 & 0 \\ 0 & 1 & 0 \\ 1 & 1 & 1 \end{matrix} \right] T=⎣⎡201011001⎦⎤ | P ′ = P T = [ x y 1 ] [ 2 0 0 0 1 0 1 1 1 ] P^{'}= PT =\left[ \begin{matrix} x & y & 1 \end{matrix} \right] \left[ \begin{matrix} 2 & 0 & 0 \\ 0 & 1 & 0 \\ 1 & 1 & 1 \end{matrix} \right] P′=PT=[xy1]⎣⎡201011001⎦⎤ | |
342 | 第13题 | 点坐标采用行向量形式 | 点坐标采用列向量形式 | |
347 | 四.填空题,第3题 | 点坐标采用行向量形式 | 点坐标采用列向量形式 | |
349 | 模1答案,二.多选题,第1题答案 | ABC | ABCD | 错切变换是沿坐标轴错切,参考对象仍为坐标原点 |
350 | 模2答案,一.单选题,第1题答案 | B | C | |
350 | 一.单选题,第3题答案 | B | C | |
350 | 一.单选题,第4题答案 | C | D | |
350 | 二.多选题,第10题答案 | ACD | ABCD | |
350 | 二.多选题,第11题答案 | CD | BCD | |
350 | 二.多选题,第13题答案 | AB | ABD | |
352 | 模3答案,一.单选题,第1题答案 | D | B | |
352 | 二.多选题,第1题答案 | BCE | AD | |
352 | 二.多选题,第2题答案 | BD | B | |
352 | 二.多选题,第6题答案 | BD | BCD | |
354 | 第1行 | [ 0 0 0 1 1 / 27 1 / 9 1 / 3 0 8 / 27 4 / 9 1 / 3 0 1 1 1 1 ] \begin{bmatrix} 0 & 0 & 0 & 1 \\ 1/27 & 1/9 & 1/3 & 0 \\ 8/27 & 4/9 & 1/3 & 0 \\ 1 & 1 & 1 & 1 \end{bmatrix} ⎣⎢⎢⎡01/278/27101/94/9101/31/311001⎦⎥⎥⎤ | [ 0 0 0 1 1 / 27 1 / 9 1 / 3 1 8 / 27 4 / 9 2 / 3 1 1 1 1 1 ] \begin{bmatrix} 0 & 0 & 0 & 1 \\ 1/27 & 1/9 & 1/3 & 1 \\ 8/27 & 4/9 & 2/3 & 1 \\ 1 & 1 & 1 & 1 \end{bmatrix} ⎣⎢⎢⎡01/278/27101/94/9101/32/311111⎦⎥⎥⎤ |
- P349, 模拟试题1,第四大题第3小题答案:
T 1 = [ 1 0 0 0 1 0 − 2 − 4 1 ] T_1= \left[ \begin{matrix} 1 & 0 & 0 \\ 0 & 1 & 0 \\ -2 & -4 & 1 \end{matrix} \right] T1=⎣⎡10−201−4001⎦⎤
T 2 = [ c o s 60 0 ∘ s i n 60 0 ∘ 0 − s i n 60 0 ∘ c o s 60 0 ∘ 0 0 0 1 ] = [ − 1 / 2 − 3 / 2 0 3 / 2 − 1 / 2 0 0 0 1 ] T_2= \left[ \begin{matrix} cos600^\circ & sin600^\circ & 0 \\ -sin600^\circ & cos600^\circ & 0 \\ 0 & 0 & 1 \end{matrix} \right] =\left[ \begin{matrix} -1/2 & -\sqrt{3}/2 & 0 \\ \sqrt{3}/2 & -1/2 & 0 \\ 0 & 0 & 1 \end{matrix} \right] T2=⎣⎡cos600∘−sin600∘0sin600∘cos600∘0001⎦⎤=⎣⎡−1/23/20−3/2−1/20001⎦⎤
T 3 = [ 1 0 0 0 1 0 2 4 1 ] T_3= \left[ \begin{matrix} 1 & 0 & 0 \\ 0 & 1 & 0 \\ 2 & 4 & 1 \end{matrix} \right] T3=⎣⎡102014001⎦⎤
T
=
T
1
T
2
T
3
=
[
−
1
/
2
−
3
/
2
0
3
/
2
−
1
/
2
0
3
−
2
3
6
+
3
1
]
T= T_1T_2T_3= \left[ \begin{matrix} -1/2 & -\sqrt{3}/2 & 0\\ \sqrt{3}/2 & -1/2 & 0 \\ 3-2 \sqrt{3} & 6+ \sqrt{3} & 1 \end{matrix} \right]
T=T1T2T3=⎣⎡−1/23/23−23−3/2−1/26+3001⎦⎤
由 $ P^{’}= PT$ 可得:
[
A
′
B
′
C
′
]
=
[
A
B
C
]
T
=
[
2
4
1
4
4
1
4
1
1
]
T
=
[
2
4
1
1
4
−
3
1
1
−
3
3
/
2
11
/
2
−
3
1
]
\left[ \begin{matrix} A^{'} \\ B^{'} \\ C^{'} \end{matrix} \right] =\left[ \begin{matrix} A \\ B \\ C \end{matrix} \right] T = \left[ \begin{matrix} 2 & 4 & 1 \\ 4 & 4 & 1 \\ 4 & 1 & 1 \end{matrix} \right] T= \left[ \begin{matrix} 2 & 4 & 1 \\ 1 & 4-\sqrt{3} & 1 \\ 1-3\sqrt{3}/2 & 11/2-\sqrt{3} & 1 \end{matrix} \right]
⎣⎡A′B′C′⎦⎤=⎣⎡ABC⎦⎤T=⎣⎡244441111⎦⎤T=⎣⎡211−33/244−311/2−3111⎦⎤
-
P350, 模拟试题1,第四大题第4小题答案:
由相似三角形关系可得 x ′ x = d d − z \frac{x^{'}} {x} = \frac{d} {d-z} xx′=d−zd于是
x ′ = x d d − z = x 1 − z d x^{'} = \frac{xd} {d-z}= \frac{x} {1-\frac{z}{d}} x′=d−zxd=1−dzx
同理有: y ′ = y 1 − z d y^{'} = \frac{y} {1-\frac{z}{d}} y′=1−dzy
另外, z ′ = 0 z^{'}=0 z′=0.
于是有:
P ′ = [ x ′ y ′ z ′ 1 ] = [ x 1 − z d y 1 − z d 0 1 ] ≡ [ x y 0 1 − z d ] = [ 1 0 0 0 0 1 0 0 0 0 0 0 0 0 − 1 d 1 ] [ x y z 1 ] = T P P^{'} = \left[ \begin{matrix} x^{'} \\ y^{'} \\ z^{'} \\ 1 \end{matrix} \right] =\left[ \begin{matrix} \frac{x} {1-\frac{z}{d}} \\ \frac{y} {1-\frac{z}{d}} \\ 0 \\ 1 \end{matrix} \right] \equiv \left[ \begin{matrix} x \\ y \\ 0 \\ 1-\frac{z}{d} \end{matrix} \right] = \left[ \begin{matrix} 1 & 0 & 0 & 0 \\ 0 & 1 & 0 & 0 \\ 0 & 0 & 0 & 0 \\ 0 & 0 & -\frac{1}{d} & 1 \\ \end{matrix} \right] \left[ \begin{matrix} x \\ y \\ z \\ 1 \end{matrix} \right] = TP P′=⎣⎢⎢⎡x′y′z′1⎦⎥⎥⎤=⎣⎢⎢⎡1−dzx1−dzy01⎦⎥⎥⎤≡⎣⎢⎢⎡xy01−dz⎦⎥⎥⎤=⎣⎢⎢⎡10000100000−d10001⎦⎥⎥⎤⎣⎢⎢⎡xyz1⎦⎥⎥⎤=TP
上式中 T T T即为透视变换矩阵,其中$ \equiv$表示齐次坐标转化。
顶点坐标计算:以G点为例,G点齐次坐标为(1,1,-1,1),则由透视变换可知:
G ′ = T G = T [ 1 1 − 1 1 ] = [ 1 0 0 0 0 1 0 0 0 0 0 0 0 0 − 1 d 1 ] [ 1 1 − 1 1 ] = [ 1 1 0 1 + 1 d ] ≡ [ d d + 1 d d + 1 0 1 ] G^{'} = TG =T \left[ \begin{matrix} 1 \\ 1 \\ -1 \\ 1 \end{matrix} \right] = \left[ \begin{matrix} 1 & 0 & 0 & 0 \\ 0 & 1 & 0 & 0 \\ 0 & 0 & 0 & 0 \\ 0 & 0 & -\frac{1}{d} & 1 \\ \end{matrix} \right] \left[ \begin{matrix} 1 \\ 1 \\ -1 \\ 1 \end{matrix} \right] = \left[ \begin{matrix} 1 \\ 1 \\ 0 \\ 1+\frac{1}{d} \end{matrix} \right] \equiv \left[ \begin{matrix} \frac{d}{d+1} \\ \frac{d}{d+1} \\ 0 \\ 1 \end{matrix} \right] G′=TG=T⎣⎢⎢⎡11−11⎦⎥⎥⎤=⎣⎢⎢⎡10000100000−d10001⎦⎥⎥⎤⎣⎢⎢⎡11−11⎦⎥⎥⎤=⎣⎢⎢⎡1101+d1⎦⎥⎥⎤≡⎣⎢⎢⎡d+1dd+1d01⎦⎥⎥⎤
故透视变换后G点变为 G ′ = ( d d + 1 , d d + 1 , 0 ) G^{'}=( \frac{d}{d+1}, \frac{d}{d+1}, 0) G′=(d+1d,d+1d,0). -
P351, 模拟试题2,第五大题第2小题答案:
c o s i = L ⃗ ⋅ N ⃗ = 0.5 , R ⃗ = 2 c o s i N ⃗ − L ⃗ = ( − 1 / 2 , 1 / 2 , − 2 / 2 ) . cosi=\vec{L} \cdot \vec{N}=0.5, \vec{R} = 2cosi\vec{N}-\vec{L}=(-1/2,1/2,-\sqrt{2}/2). cosi=L⋅N=0.5,R=2cosiN−L=(−1/2,1/2,−2/2).
c o s θ = R ⃗ ⋅ V ⃗ = − 2 / 2 < 0 , R ⃗ 与 V ⃗ 夹 角 大 于 90 度 , 因 此 V ⃗ 方 向 上 无 镜 面 反 射 光 , 所 以 c o s θ 取 0. cos\theta= \vec{R} \cdot \vec{V} = -\sqrt{2}/2<0, \vec{R}与\vec{V}夹角大于90度,因此\vec{V}方向上无镜面反射光,所以 cos\theta取0. cosθ=R⋅V=−2/2<0,R与V夹角大于90度,因此V方向上无镜面反射光,所以cosθ取0.
∴ I = I p a k a + I p ( k d c o s i + k s c o s n θ ) = 160 ∗ 0.5 + 175 ( 0.2 ∗ 0.5 + 0 ) = 97.5 \therefore I=I_{pa}k_a+I_p(k_dcosi+k_scos^n\theta)=160*0.5+175(0.2*0.5+0)=97.5 ∴I=Ipaka+Ip(kdcosi+kscosnθ)=160∗0.5+175(0.2∗0.5+0)=97.5 -
P353, 模拟试题3,第五大题第1小题答案:
a = y 0 − y 1 = − 4 , b = x 1 − x 0 = 8 , d 0 = a + 0.5 b = 0 ; a + b = 4 , a = − 4 a=y_0-y_1=-4, b=x_1-x_0=8, d_0=a+0.5b=0; a+b=4, a=-4 a=y0−y1=−4,b=x1−x0=8,d0=a+0.5b=0;a+b=4,a=−4,当 d i < 0 d_i<0 di<0时,中点M在直线下方,下一点取当前点P的右上方点,记为NE,同时 d i + 1 = d i + a + b d_{i+1}=d_i+a+b di+1=di+a+b;当 d i ≥ 0 d_i\geq0 di≥0时,中点M在直线上方,下一点取当前点P的右侧点,记为E,同时 d i + 1 = d i + a d_{i+1}=d_i+a di+1=di+a。根据中点线算法原理可得下表:
x | y | d i d_i di | Next Point |
---|---|---|---|
2 | 1 | 0 | E |
3 | 1 | 0-4=-4 | NE |
4 | 2 | -4+4=0 | E |
5 | 2 | 0-4=-4 | NE |
6 | 3 | -4+4=0 | E |
7 | 3 | 0-4=-4 | NE |
8 | 4 | -4+4=0 | E |
9 | 4 | 0-4=-4 | NE |
10 | 5 |