前言
如果你对这篇文章可感兴趣,可以点击「【访客必读 - 指引页】一文囊括主页内所有高质量博客」,查看完整博客分类与对应链接。
文章目录
第六章 三维图形变换
6.1 三维图形几何变换
6.1.1 几何变换概述
三维基本几何变换皆是相对于坐标原点和坐标轴进行的几何变换。与二维变换类似,引入齐次坐标表示,即三维空间中某点的变换可以表示成点的齐次坐标与四阶的三维变换矩阵相乘。
- p ′ = [ x ∗ y ∗ z ∗ 1 ] = [ x y z 1 ] ⋅ [ a b c p d e f q g h i r l m n s ] p' = \left[ \begin{matrix} x^* & y^* & z^* & 1\end{matrix}\right] =\left[ \begin{matrix} x & y & z & 1 \end{matrix}\right]· \left[ \begin{matrix} a&b&c&p\\d&e&f&q\\g&h&i&r\\l&m&n&s \end{matrix} \right] p′=[x∗y∗z∗1]=[xyz1]⋅ adglbehmcfinpqrs
6.1.2 平移变换
- [ x ′ y ′ z ′ 1 ] = [ x y z 1 ] ⋅ T t = [ x y z 1 ] ⋅ [ 1 0 0 0 0 1 0 0 0 0 1 0 T x T y T z 1 ] = [ x + T x y + T y z + T z 1 ] \left[ \begin{matrix} x' & y' & z' & 1\end{matrix}\right]=\left[ \begin{matrix} x & y & z & 1\end{matrix}\right]·T_t=\left[ \begin{matrix} x & y & z & 1\end{matrix}\right] · \left[ \begin{matrix} 1&0&0&0\\0&1&0&0\\0&0&1&0\\T_x&T_y&T_z&1 \end{matrix} \right] = \left[ \begin{matrix} x+T_x & y+T_y & z+T_z & 1\end{matrix}\right] [x′y′z′1]=[xyz1]⋅Tt=[xyz1]⋅ 100Tx010Ty001Tz0001 =[x+Txy+Tyz+Tz1]
6.1.3 比例变换
- 局部比例变换: [ x ′ y ′ z ′ 1 ] = [ x y z 1 ] ⋅ T s = [ x y z 1 ] ⋅ [ a 0 0 0 0 e 0 0 0 0 i 0 0 0 0 1 ] = [ a x e y i z 1 ] \left[ \begin{matrix} x' & y' & z' & 1\end{matrix}\right]=\left[ \begin{matrix} x & y & z & 1\end{matrix}\right]·T_s=\left[ \begin{matrix} x & y & z & 1\end{matrix}\right] ·\left[ \begin{matrix} a&0&0&0\\0&e&0&0\\0&0&i&0\\0&0&0&1 \end{matrix} \right] = \left[ \begin{matrix} ax&ey&iz & 1\end{matrix}\right] [x′y′z′1]=[xyz1]⋅Ts=[xyz1]⋅ a0000e0000i00001 =[axeyiz1]
- 整体比例变换: [ x ′ y ′ z ′ 1 ] = [ x y z 1 ] ⋅ T s = [ x y z 1 ] ⋅ [ 1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 s ] = [ x y z s ] \left[ \begin{matrix} x' & y' & z' & 1\end{matrix}\right]=\left[ \begin{matrix} x & y & z & 1\end{matrix}\right]·T_s=\left[ \begin{matrix} x & y & z & 1\end{matrix}\right] ·\left[ \begin{matrix} 1&0&0&0\\0&1&0&0\\0&0&1&0\\0&0&0&s \end{matrix} \right] = \left[ \begin{matrix} x&y&z & s\end{matrix}\right] [x′y′z′1]=[xyz1]⋅Ts=[xyz1]⋅ 100001000010000s =[xyzs]
6.1.4 旋转变换
三维立体的旋转变换是指给定的三维立体绕三维空间某个指定的坐标轴旋转 $ \theta$ 角度。旋转后,立体的空间位置将发生变化,但形状不变。
- 右手定则:右手大拇指指向旋转轴的正向,其余四指指向旋转角的正向
-
绕 z 轴旋转: [ x y z 1 ] ⋅ [ c o s θ s i n θ 0 0 − s i n θ c o s θ 0 0 0 0 1 0 0 0 0 1 ] = [ x ⋅ c o s θ − y ⋅ s i n θ x ⋅ s i n θ + y ⋅ c o s θ z 1 ] \left[ \begin{matrix} x & y&z & 1 \end{matrix}\right]· \left[ \begin{matrix} cos\theta & sin\theta &0&0\\-sin\theta&cos\theta & 0&0\\0&0&1&0\\0&0&0&1 \end{matrix} \right] =\left[ \begin{matrix} x ·cos\theta-y ·sin\theta & x ·sin\theta + y ·cos\theta &z&1\end{matrix}\right] [xyz1]⋅ cosθ−sinθ00sinθcosθ0000100001 =[x⋅cosθ−y⋅sinθx⋅sinθ+y⋅cosθz1]
-
绕 x 轴旋转: [ x y z 1 ] ⋅ [ 1 0 0 0 0 c o s θ s i n θ 0 0 − s i n θ c o s θ 0 0 0 0 1 ] = [ x y ⋅ c o s θ − z ⋅ s i n θ y ⋅ s i n θ + z ⋅ c o s θ 1 ] \left[ \begin{matrix} x & y&z & 1 \end{matrix}\right]· \left[ \begin{matrix} 1&0&0&0\\ 0&cos\theta & sin\theta &0\\0&-sin\theta&cos\theta & 0\\0&0&0&1 \end{matrix} \right] =\left[ \begin{matrix} x & y·cos\theta-z ·sin\theta & y ·sin\theta + z ·cos\theta &1\end{matrix}\right] [xyz1]⋅ 10000cosθ−sinθ00sinθcosθ00001 =[xy⋅cosθ−z⋅sinθy⋅sinθ+z⋅cosθ1]
-
绕 y 轴旋转: [ x y z 1 ] ⋅ [ c o s θ 0 − s i n θ 0 0 1 0 0 s i n θ 0 c o s θ 0 0 0 0 1 ] = [ x ⋅ s i n θ + x ⋅ c o s θ y z ⋅ c o s θ − x ⋅ s i n θ 1 ] \left[ \begin{matrix} x & y&z & 1 \end{matrix}\right]· \left[ \begin{matrix} cos\theta &0& -sin\theta &0\\0&1&0&0\\ sin\theta&0&cos\theta &0\\0&0&0&1 \end{matrix} \right] =\left[ \begin{matrix} x·sin\theta+x·cos\theta & y & z·cos\theta-x·sin\theta & 1 \end{matrix}\right] [xyz1]⋅ cosθ0sinθ00100−sinθ0cosθ00001 =[x⋅sinθ+x⋅cosθyz⋅cosθ−x⋅sinθ1]
-
绕任意轴旋转
- 先将轴移动到坐标原点,再将轴旋转到坐标轴上
- 进行几何变换
- 将轴反旋转,再反平移到原来位置
6.1.5 对称变换
- 关于坐标平面的对称
- 关于 x 0 y x0y x0y 平面对称: T = [ 1 0 0 0 0 1 0 0 0 0 − 1 0 0 0 0 1 ] T = \left[ \begin{matrix} 1&0&0&0\\0&1&0&0\\0&0&-1&0\\0&0&0&1 \end{matrix} \right] T= 1000010000−100001 , [ x ′ y ′ z ′ 1 ] = [ x y − z 1 ] [x'\ y'\ z'\ 1]=[x\ y \ -z\ \ 1] [x′ y′ z′ 1]=[x y −z 1]
- 关于 y 0 z y0z y0z 平面对称: T = [ − 1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 ] T = \left[ \begin{matrix} -1&0&0&0\\0&1&0&0\\0&0&1&0\\0&0&0&1 \end{matrix} \right] T= −1000010000100001 , [ x ′ y ′ z ′ 1 ] = [ − x y z 1 ] [x'\ y'\ z'\ 1]=[-x\ y \ z\ 1] [x′ y′ z′ 1]=[−x y z 1]
- 关于 z 0 x z0x z0x 平面对称: T = [ 1 0 0 0 0 − 1 0 0 0 0 1 0 0 0 0 1 ] T = \left[ \begin{matrix} 1&0&0&0\\0&-1&0&0\\0&0&1&0\\0&0&0&1 \end{matrix} \right] T= 10000−10000100001 , [ x ′ y ′ z ′ 1 ] = [ x − y z 1 ] [x'\ y'\ z'\ 1]=[x\ -y \ \ z \ 1] [x′ y′ z′ 1]=[x −y z 1]
- 关于坐标轴的对称
- 关于 x x x 轴对称: T = [ 1 0 0 0 0 − 1 0 0 0 0 − 1 0 0 0 0 1 ] T = \left[ \begin{matrix} 1&0&0&0\\0&-1&0&0\\0&0&-1&0\\0&0&0&1 \end{matrix} \right] T= 10000−10000−100001 , [ x ′ y ′ z ′ 1 ] = [ x − y − z 1 ] [x'\ y'\ z'\ 1]=[x\ \ -y \ -z\ \ 1] [x′ y′ z′ 1]=[x −y −z 1]
- 关于 x x x 轴对称: T = [ − 1 0 0 0 0 1 0 0 0 0 − 1 0 0 0 0 1 ] T = \left[ \begin{matrix} -1&0&0&0\\0&1&0&0\\0&0&-1&0\\0&0&0&1 \end{matrix} \right] T= −1000010000−100001 , [ x ′ y ′ z ′ 1 ] = [ − x y − z 1 ] [x'\ y'\ z'\ 1]=[-x\ \ y \ -z\ \ 1] [x′ y′ z′ 1]=[−x y −z 1]
- 关于 z z z 轴对称: T = [ − 1 0 0 0 0 − 1 0 0 0 0 1 0 0 0 0 1 ] T = \left[ \begin{matrix} -1&0&0&0\\0&-1&0&0\\0&0&1&0\\0&0&0&1 \end{matrix} \right] T= −10000−10000100001 , [ x ′ y ′ z ′ 1 ] = [ − x − y z 1 ] [x'\ y'\ z'\ 1]=[-x\ -y \ \ z\ \ 1] [x′ y′ z′ 1]=[−x −y z 1]
6.2 投影变换分类
投影变换:解决三维输出到二维
- 投影法分类(区别在于投影中心到投影面之间的距离是有/无限的):
- 透视投影法(中心投影法),比如建筑透视
- 生成真实感视图但不保持相关比例
- 平行投影法
- 正投影法,比如工程样图
- 斜投影法
- 保持物体的有关比例不变,物体的各个面的精确视图由平行投影而得,没有给出三维物体外表的真实性表示
6.3 平行投影 (三视图、轴测图)
6.3.1 平行投影概述
- 特点
- 物体各个面的精确视图又平行投影而得
- 没有给出三维物体外表的真实性但保持比例
6.3.2 三视图
- 主视图变换矩阵
- T = [ 1 0 0 0 0 0 0 0 0 0 1 0 0 0 0 1 ] T = \left[ \begin{matrix} 1&0&0&0\\0&0&0&0\\0&0&1&0\\0&0&0&1 \end{matrix} \right] T= 1000000000100001 ,投影在 x 0 z x0z x0z 面,直接将 y y y 置 0 0 0 .
- 俯视图变换矩阵
-
T
=
[
1
0
0
0
0
0
−
1
0
0
0
0
0
0
0
−
z
0
1
]
T = \left[ \begin{matrix} 1&0&0&0\\0&0&-1&0\\0&0&0&0\\0&0&-z_0&1 \end{matrix} \right]
T=
100000000−10−z00001
,下述为推导过程
- 投影在 x 0 y x0y x0y 面,直接置 z = 0 z=0 z=0, T = [ 1 0 0 0 0 1 0 0 0 0 0 0 0 0 0 1 ] T = \left[ \begin{matrix} 1&0&0&0\\0&1&0&0\\0&0&0&0\\0&0&0&1 \end{matrix} \right] T= 1000010000000001
- 为了使俯视图与主视图都画在一个平面内,就要使 H H H 面绕 x x x 轴顺时针转90°,进入 x 0 z x0z x0z 面 T = [ 1 0 0 0 0 c o s ( − 9 0 ∘ ) s i n ( − 9 0 ∘ ) 0 0 − s i n ( − 9 0 ∘ ) c o s ( − 9 0 ∘ ) 0 0 0 0 1 ] = [ 1 0 0 0 0 0 − 1 0 0 1 0 0 0 0 0 1 ] T = \left[ \begin{matrix} 1&0&0&0\\0&cos(-90^ \circ)&sin(-90^ \circ)&0\\0&-sin(-90^ \circ)&cos(-90^ \circ)&0\\0&0&0&1 \end{matrix} \right] =\left[ \begin{matrix} 1&0&0&0\\0&0&-1&0\\0&1&0&0\\0&0&0&1 \end{matrix} \right] T= 10000cos(−90∘)−sin(−90∘)00sin(−90∘)cos(−90∘)00001 = 100000100−1000001
- 为了使主视图和俯视图有一定的间距,还要使 H H H 面沿 z z z 方向平移一段距离 − z 0 -z_0 −z0 , T = [ 1 0 0 0 0 1 0 0 0 0 1 0 0 0 − z 0 1 ] T = \left[ \begin{matrix} 1&0&0&0\\0&1&0&0\\0&0&1&0\\0&0&-z_0 &1 \end{matrix} \right] T= 10000100001−z00001
-
T
=
[
1
0
0
0
0
0
−
1
0
0
0
0
0
0
0
−
z
0
1
]
T = \left[ \begin{matrix} 1&0&0&0\\0&0&-1&0\\0&0&0&0\\0&0&-z_0&1 \end{matrix} \right]
T=
100000000−10−z00001
,下述为推导过程
- 侧视图变换矩阵
-
T
=
[
0
0
0
0
−
1
0
0
0
0
0
1
0
−
x
0
0
0
1
]
T = \left[ \begin{matrix} 0&0&0&0\\-1&0&0&0\\0&0&1&0\\-x_0&0&0&1 \end{matrix} \right]
T=
0−10−x0000000100001
,下述为推导过程
- 投影在 y 0 z y0z y0z面,直接置 x = 0 x=0 x=0, T = [ 0 0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 ] T = \left[ \begin{matrix} 0&0&0&0\\0&1&0&0\\0&0&1&0\\0&0&0&1 \end{matrix} \right] T= 0000010000100001
- 为了使侧视图与主视图也在一个平面内,就要使 W W W 面绕 z z z 轴正转90°,进入 x 0 z x0z x0z 面 T = [ c o s ( − 9 0 ∘ ) s i n ( − 9 0 ∘ ) 0 0 − s i n ( − 9 0 ∘ ) c o s ( − 9 0 ∘ ) 0 0 0 0 1 0 0 0 0 1 ] = [ 0 1 0 0 − 1 0 0 0 0 0 1 0 0 0 0 1 ] T = \left[ \begin{matrix} cos(-90^ \circ)&sin(-90^ \circ)&0&0\\-sin(-90^ \circ)&cos(-90^ \circ)&0&0\\0&0&1&0\\0&0&0&1 \end{matrix} \right] =\left[ \begin{matrix} 0&1&0&0\\-1&0&0&0\\0&0&1&0\\0&0&0&1 \end{matrix} \right] T= cos(−90∘)−sin(−90∘)00sin(−90∘)cos(−90∘)0000100001 = 0−100100000100001
- 为使主视图和侧视图有一定的间距,还要使 W W W 面沿负 x x x 方向平移一段距离 − x 0 -x_0 −x0, T = [ 1 0 0 0 0 1 0 0 0 0 1 0 − x 0 0 0 1 ] T = \left[ \begin{matrix} 1&0&0&0\\0&1&0&0\\0&0&1&0\\-x_0&0&0 &1 \end{matrix} \right] T= 100−x0010000100001
-
T
=
[
0
0
0
0
−
1
0
0
0
0
0
1
0
−
x
0
0
0
1
]
T = \left[ \begin{matrix} 0&0&0&0\\-1&0&0&0\\0&0&1&0\\-x_0&0&0&1 \end{matrix} \right]
T=
0−10−x0000000100001
,下述为推导过程
- 主视图: [ x ′ y ′ z ′ 1 ] = [ x 0 z 1 ] \left[ \begin{matrix} x' & y'&z' & 1 \end{matrix}\right] = \left[ \begin{matrix} x & 0&z & 1 \end{matrix}\right] [x′y′z′1]=[x0z1]
- 俯视图: [ x ′ y ′ z ′ 1 ] = [ x 0 − ( y + z 0 ) 1 ] \left[ \begin{matrix} x' & y'&z' & 1 \end{matrix}\right] = \left[ \begin{matrix} x & 0&-(y+z_0 ) & 1 \end{matrix}\right] [x′y′z′1]=[x0−(y+z0)1]
- 侧视图: [ x ′ y ′ z ′ 1 ] = [ − ( y + x 0 ) 0 z 1 ] \left[ \begin{matrix} x' & y'&z' & 1 \end{matrix}\right] = \left[ \begin{matrix} -(y+x_0) & 0&z & 1 \end{matrix}\right] [x′y′z′1]=[−(y+x0)0z1]
- 三个视图中的 y ’ y’ y’ 均为 0 0 0,表明三个视图均落在 x 0 z x0z x0z 面上
6.3.3 正轴侧
- 等轴侧:当投影面与三个坐标轴之间的夹角都相等
- 正二测:当投影面与两个坐标轴之间的夹角相等
- 正三测:当投影面与三个坐标轴之间的夹角都不相等
-
正轴侧变换矩阵:
- 以 V V V 面为轴测投影面 (三视图中的 x 0 z x0z x0z 面),先将物体绕 Z Z Z 轴转 γ γ γ 角,接着绕 X X X 轴转 − α -α −α 角,最后向 V V V 面投影
- T 正 = T Z ⋅ T X ⋅ T V = [ c o s γ s i n γ 0 0 − s i n γ c o s γ 0 0 0 0 1 0 0 0 0 1 ] ⋅ [ 1 0 0 0 0 c o s α − s i n α 0 0 s i n α c o s α 0 0 0 0 1 ] ⋅ [ 1 0 0 0 0 0 0 0 0 0 1 0 0 0 0 1 ] = [ c o s γ 0 − s i n γ s i n α 0 − s i n γ 0 − c o s γ s i n α 0 0 0 c o s α 0 0 0 0 1 ] T_正 = T_Z ·T_X·T_V = \left[ \begin{matrix} cos\gamma & sin\gamma & 0&0\\-sin\gamma & cos\gamma & 0& 0 \\ 0&0&1&0\\0&0&0&1 \end{matrix} \right] · \left[ \begin{matrix} 1&0&0&0\\0&cos\alpha&-sin\alpha&0\\0&sin\alpha&cos\alpha&0\\0&0&0&1 \end{matrix} \right] · \left[ \begin{matrix} 1&0&0&0\\0&0&0&0\\0&0&1&0\\0&0&0&1 \end{matrix} \right] \\ = \left[ \begin{matrix} cos\gamma & 0 & -sin\gamma sin\alpha &0\\ -sin\gamma & 0&-cos\gamma sin\alpha & 0 \\ 0&0&cos\alpha&0\\0&0&0&1 \end{matrix} \right] T正=TZ⋅TX⋅TV= cosγ−sinγ00sinγcosγ0000100001 ⋅ 10000cosαsinα00−sinαcosα00001 ⋅ 1000000000100001 = cosγ−sinγ000000−sinγsinα−cosγsinαcosα00001
- 即 [ x ′ y ′ z ′ 1 ] = [ x c o s γ − y s i n γ 0 − x s i n γ s i n α − y c o s γ s i n α + z c o s α 1 ] \left[ \begin{matrix} x' & y'&z' & 1 \end{matrix}\right] = \left[ \begin{matrix} xcos\gamma-ysin\gamma & 0& -xsin\gamma sin\alpha-ycos\gamma sin\alpha + zcos\alpha & 1 \end{matrix}\right] [x′y′z′1]=[xcosγ−ysinγ0−xsinγsinα−ycosγsinα+zcosα1]
-
正等轴测图:取 γ = 4 5 ∘ , α = − 35.2 6 ∘ \gamma = 45^\circ , \alpha = -35.26^\circ γ=45∘,α=−35.26∘, T 正等轴测 = [ 0.7071 0 − 0.4082 0 − 0.7071 0 − 0.4082 0 0 0 0.8165 0 0 0 0 1 ] T_{\text{正等轴测}} = \left[ \begin{matrix} 0.7071&0&-0.4082&0\\-0.7071&0&-0.4082&0\\0&0&0.8165&0\\0&0&0&1 \end{matrix} \right] T正等轴测= 0.7071−0.7071000000−0.4082−0.40820.816500001
-
正二测图:取 γ = 20. 7 ∘ , α = 19.4 7 ∘ \gamma = 20.7^\circ , \alpha = 19.47^\circ γ=20.7∘,α=19.47∘, T 正二测 = [ 0.9354 0 − 0.1178 0 − 0.7071 0 − 0.3118 0 0 0 0.9428 0 0 0 0 1 ] T_{\text{正二测}} = \left[ \begin{matrix} 0.9354&0&-0.1178&0\\-0.7071&0&-0.3118&0\\0&0&0.9428&0\\0&0&0&1 \end{matrix} \right] T正二测= 0.9354−0.7071000000−0.1178−0.31180.942800001
6.4 透视投影
6.4.1 透视投影概述
- 特点
- 物体投影视图由计算投影线与观察平面之交点而得
- 生成真实感视图但不保持比例
- 三维变换矩阵, T 3 D = [ a b c p d e f q g h i r l m n s ] T_{3D} = \left[ \begin{matrix} a&b&c&p\\d&e&f&q\\g&h&i&r\\l&m&n&s \end{matrix} \right] T3D= adglbehmcfinpqrs ,其中 p、q、r 能产生透视变换的效果。
6.4.2 一点透视
- 假设 q ≠ 0 , p = r = 0 q \not=0,p=r=0 q=0,p=r=0
- [ x y z 1 ] ⋅ [ 1 0 0 0 0 1 0 q 0 0 1 0 0 0 0 1 ] = [ x y z q y + 1 ] \left[ \begin{matrix} x&y&z&1 \end{matrix} \right]· \left[ \begin{matrix} 1&0&0&0\\0&1&0&q\\0&0&1&0\\0&0&0&1 \end{matrix} \right] =\left[ \begin{matrix} x&y&z&qy+1 \end{matrix} \right] [xyz1]⋅ 1000010000100q01 =[xyzqy+1]
- 齐次化后:
[
x
′
y
′
z
′
1
]
=
[
x
q
y
+
1
y
q
y
+
1
z
q
y
+
1
1
]
\left[ \begin{matrix} x'&y'&z'&1 \end{matrix} \right]=\left[ \begin{matrix} \frac{x}{qy+1}&\frac{y}{qy+1}&\frac{z}{qy+1}&1 \end{matrix} \right]
[x′y′z′1]=[qy+1xqy+1yqy+1z1]
- 当 y = 0 y=0 y=0 时, [ x ′ y ′ z ′ 1 ] = [ x 0 z 1 ] \left[ \begin{matrix} x'&y'&z'&1 \end{matrix} \right]=\left[ \begin{matrix}x&0&z&1 \end{matrix} \right] [x′y′z′1]=[x0z1],即处于 y=0 平面内的点变换后无变化
- 当 y → ∞ y\rightarrow∞ y→∞时, [ x ′ y ′ z ′ 1 ] = [ 0 1 q 0 1 ] \left[ \begin{matrix} x'&y'&z'&1 \end{matrix} \right]=\left[ \begin{matrix}0&\frac{1}{q}&0&1 \end{matrix} \right] [x′y′z′1]=[0q101],所有点都集中到y轴的1/q处,这点叫灭点
- 只形成一个灭点的透视变换即为一点透视。
- 同样的分别假设 p p p、 r r r 其中一个不为 0 0 0 ,另外两个为 0 0 0 ,都会产生一个灭点 ( 1 p , 0 , 0 ) (\frac{1}{p}, 0, 0) (p1,0,0)、 ( 0 , 0 , 1 r ) (0, 0, \frac{1}{r}) (0,0,r1)。
6.4.3 多点透视
- 根据一点透视的原理予以推广,如果
p
p
p、
q
q
q、
r
r
r 三个元素中有两个为非零元素时,将会生成两个灭点,因此得到两点透视;相应的三点透视概念也可得知。
- 如当 p ≠ 0 , r ≠ 0 p\not=0,r\not=0 p=0,r=0, [ x y z 1 ] ⋅ [ 1 0 0 p 0 1 0 0 0 0 1 r 0 0 0 1 ] = [ x y z p x + r z + 1 ] \left[ \begin{matrix} x&y&z&1 \end{matrix} \right]· \left[ \begin{matrix} 1&0&0&p\\0&1&0&0\\0&0&1&r\\0&0&0&1 \end{matrix} \right] =\left[ \begin{matrix} x&y&z&px+rz+1 \end{matrix} \right] [xyz1]⋅ 100001000010p0r1 =[xyzpx+rz+1]
- 齐次化后: [ x ′ y ′ z ′ 1 ] = [ x p x + r z + 1 y p x + r z + 1 z p x + r z + 1 1 ] \left[ \begin{matrix} x'&y'&z'&1 \end{matrix} \right]=\left[ \begin{matrix} \frac{x}{px+rz+1}&\frac{y}{px+rz+1}&\frac{z}{px+rz+1}&1 \end{matrix} \right] [x′y′z′1]=[px+rz+1xpx+rz+1ypx+rz+1z1]
- 分别看到两个灭点, ( 1 p , 0 , 0 ) (\frac{1}{p}, 0, 0) (p1,0,0)、 ( 0 , 0 , 1 r ) (0, 0, \frac{1}{r}) (0,0,r1)
6.4.4 生成透视投影图的方法
- 设投影中心:c(0, 0, -d),现在推空间一点 p ( x , y , z ) p(x, y, z) p(x,y,z) 的透视投影点 p ′ ( x ′ , y ′ , z ′ ) p'(x', y', z') p′(x′,y′,z′)
- △ A B C ∼ △ A ′ O C ⇒ x ′ x = y ′ y = d d + z ⇒ x ′ = x 1 + z / d , y ′ = y 1 + z / d , z ′ = 0 \large \triangle ABC \sim \triangle A'OC \Rightarrow \frac{x'}{x} =\frac{y'}{y} = \frac{d}{d+z} \Rightarrow x'= \frac{x}{1+z/d},y' = \frac{y}{1+z/d},z' = 0 △ABC∼△A′OC⇒xx′=yy′=d+zd⇒x′=1+z/dx,y′=1+z/dy,z′=0
- 矩阵形式是:
[
x
y
z
1
]
⋅
[
1
0
0
0
0
1
0
0
0
0
1
1
d
0
0
0
1
]
=
[
x
y
z
z
d
+
1
]
\left[ \begin{matrix} x&y&z&1 \end{matrix} \right]· \left[ \begin{matrix} 1&0&0&0\\0&1&0&0\\0&0&1&\frac{1}{d}\\0&0&0&1 \end{matrix} \right] =\left[ \begin{matrix} x&y&z&\frac{z}{d}+1 \end{matrix} \right]
[xyz1]⋅
10000100001000d11
=[xyzdz+1]
- 透视坐标与 z z z 值成反比。即 z z z 值越大,透视坐标值越小
- d d d 的取值不同,可以对形成的透视图有放大和缩小的功能。当值较大时,形成的透视图变大;反之缩小。
- 再乘以向投影面投影的变换矩阵,就得到点在画面上的投影
[
x
y
z
1
]
⋅
[
1
0
0
0
0
1
0
0
0
0
1
1
d
0
0
0
1
]
⋅
[
1
0
0
0
0
1
0
0
0
0
0
0
0
0
0
1
]
\left[ \begin{matrix} x&y&z&1 \end{matrix} \right]· \left[ \begin{matrix} 1&0&0&0\\0&1&0&0\\0&0&1&\frac{1}{d}\\0&0&0&1 \end{matrix} \right] · \left[ \begin{matrix} 1&0&0&0\\0&1&0&0\\0&0&0&0\\0&0&0&1 \end{matrix} \right]
[xyz1]⋅
10000100001000d11
⋅
1000010000000001
- 若投影中心在无穷远处,则 1 d → 0 \frac{1}{d} \rightarrow 0 d1→0,上式变为平行投影。
6.4.5 一点透视投影实例
- 设 l = − 0.8 l=-0.8 l=−0.8, m = − 1.6 m=-1.6 m=−1.6, n = − 2 n=-2 n=−2, 视距 d = − 2.5 d=-2.5 d=−2.5
6.4.6 二点透视投影实例:
- 将物体平移到适当位置 l 、 m 、 n l、m、n l、m、n
- 将物体绕 y y y 轴旋转 θ θ θ 角
- 进行透视变换
- 最后向 x 0 y x0y x0y 面做正投影,即得二点透视图