三维变换
和上节一样,我们使用齐次坐标
- 3D点: ( x , y , z , 1 ) ⊤ (x,y,z,1)^\top (x,y,z,1)⊤
- 3D向量: ( x , y , z , 0 ) ⊤ (x,y,z,0)^\top (x,y,z,0)⊤
通常情况下, w ≠ 0 w\neq0 w=0,3D点表示为 ( x / w , y / w , z / w , 1 ) ⊤ (x/w,y/w,z/w,1)^\top (x/w,y/w,z/w,1)⊤
则我们可以使用 4 × 4 4\times4 4×4矩阵表示仿射变换
[ x ′ y ′ z ′ 1 ] = [ a b c t x d e f t y g h i t z 0 0 0 1 ] [ x y z 1 ] (1) \left[\begin{array}{l} x^{\prime} \\ y^{\prime} \\ z^{\prime} \\ 1 \end{array}\right]=\left[\begin{array}{ll} a & b & c & t_x \\ d & e & f & t_y \\ g & h & i & t_z \\ 0 & 0 & 0 & 1 \end{array}\right]\left[\begin{array}{l} x \\ y \\ z \\ 1 \end{array}\right] \tag{1} ⎣⎢⎢⎡x′y′z′1⎦⎥⎥⎤=⎣⎢⎢⎡adg0beh0cfi0txtytz1⎦⎥⎥⎤⎣⎢⎢⎡xyz1⎦⎥⎥⎤(1)
缩放
S ( s x , s y , s z ) = [ s x 0 0 t x 0 s y 0 t y 0 0 s z t z 0 0 0 1 ] (2) \bold{S}(s_x,s_y,s_z)= \left[\begin{array}{ll} s_x & 0 & 0 & t_x \\ 0 & s_y & 0 & t_y \\ 0 & 0 & s_z & t_z \\ 0 & 0 & 0 & 1 \end{array}\right] \tag{2} S(sx,sy,sz)=⎣⎢⎢⎡sx0000sy0000sz0txtytz1⎦⎥⎥⎤(2)
平移
T ( t x , t y , t z ) = [ 1 0 0 t x 0 1 0 t y 0 0 1 t z 0 0 0 1 ] (3) \bold{T}(t_x,t_y,t_z)= \left[\begin{array}{ll} 1 & 0 & 0 & t_x \\ 0 & 1 & 0 & t_y \\ 0 & 0 & 1 & t_z \\ 0 & 0 & 0 & 1 \end{array}\right] \tag{3} T(tx,ty,tz)=⎣⎢⎢⎡100001000010txtytz1⎦⎥⎥⎤(3)
旋转
绕 x x x轴旋转
R x ( α ) = [ 1 0 0 t x 0 cos α − sin α t y 0 sin α cos α t z 0 0 0 1 ] (4) \bold{R}_x(\alpha)= \left[\begin{array}{c} 1 & 0 & 0 & t_x \\ 0 & \cos\alpha & -\sin\alpha & t_y \\ 0 & \sin\alpha & \cos\alpha & t_z \\ 0 & 0 & 0 & 1 \end{array}\right] \tag{4} Rx(α)=⎣⎢⎢⎡10000cosαsinα00−sinαcosα0