Chapter 6 Transformation Matrices

(个人笔记,由于刚开始学习再加上英语不太好,所以有的地理解的可能不太对,望指正)

Chapter 6 Transformation Matrices

6.1 2D Linear Transformation

6.1.1 Scaling

scale(sx,sy)=[sx00sy] scale(s_x, s_y) = \begin{bmatrix} s_x & 0 \\ 0 & s_y \end{bmatrix}

6.1.2 Shearing

shearX(s)=[1s01]shearY(s)=[10s1] shearX(s) = \begin{bmatrix} 1 & s \\ 0 & 1 \end{bmatrix} \\ shearY(s) = \begin{bmatrix} 1 & 0 \\ s & 1 \end{bmatrix}

shear操作可以看作是只沿一个方向进行旋转

6.1.3 Rotation

rotate(ϕ)=[cosϕsinϕsinϕcosϕ] rotate(\phi)=\begin{bmatrix} cos\phi & -sin\phi \\ sin\phi & cos\phi \end{bmatrix}

计算过程:

r=xa2+ya2xa=rcosαya=rsinαxb=rcos(α+ϕ)=rcosαcosϕrsinαsinϕyb=rsin(α+ϕ)=rsinαcosϕ+rcosαsinϕ r = \sqrt{x_a^2 + y_a^2} \\ x_a = r cos\alpha \\ y_a = r sin \alpha \\ x_b = r cos(\alpha + \phi) = rcos\alpha cos\phi - rsin\alpha sin\phi \\ y_b = r sin(\alpha + \phi) = rsin\alpha cos\phi + rcos\alpha sin\phi

如图所示:

Chapter 6 Transformation Matrices

旋转矩阵是正交矩阵

6.1.4 Reflection

reflectY=[1001]reflectX=[1001] reflectY = \begin{bmatrix} -1 & 0 \\ 0 & 1 \end{bmatrix} \\ reflectX = \begin{bmatrix} 1 & 0 \\ 0 & -1 \end{bmatrix}

6.1.5 Composition and Decomposition of Transformations

6.1.6 Decoposition of Transformations

Symmetric Eigenvalue Decomposition

对于对称矩阵来说,可以进行以下分解过程:

A=RSRT A = RSR^{T}

R表示旋转,S表示缩放。

Singular Value Decomposition

对于非对称矩阵来说,可以使用奇异值分解。

A=USVT A = USV^{T}

对于奇异值分解来说UV可能不表示旋转,也可能表示反射,可以通过行列式的值判断:+1表示旋转,-1表示反射。

Paeth Decomposition of Rotations

使用shear操作代替旋转操作

[cosϕsinϕsinϕcosϕ]=[1cosϕ1sinϕ01][10sinϕ1][1cosϕ1sinϕ01] \begin{bmatrix} cos\phi & -sin\phi \\ sin\phi & cos\phi \end{bmatrix}=\begin{bmatrix} 1 & \frac{cos\phi-1}{sin\phi} \\ 0 & 1 \end{bmatrix}\begin{bmatrix} 1 & 0 \\ sin\phi & 1 \end{bmatrix}\begin{bmatrix} 1 & \frac{cos\phi-1}{sin\phi} \\ 0 & 1 \end{bmatrix}

该转化对于raster rotation非常有效,因为对于raster operation来说,shear操作是很高效的。

6.2 3D Linear Transformations

缩放

scale(sx,sy,sz)=[sx000sy000sz] scale(s_x, s_y, s_z) = \begin{bmatrix} s_x & 0 & 0 \\ 0 & s_y & 0 \\ 0 & 0 & s_z \end{bmatrix}

旋转

rotateZ(ϕ)=[cosϕsinϕ0sinϕcosϕ0001]rotateX(ϕ)=[10cosϕsinϕ0sinϕcosϕ0]rotateY(ϕ)=[cosϕ0sinϕ010sinϕ0cosϕ] rotateZ(\phi)=\begin{bmatrix} cos\phi & -sin\phi & 0 \\ sin\phi & cos\phi & 0 \\ 0 & 0 & 1 \end{bmatrix} \\ rotateX(\phi)=\begin{bmatrix} 1 & 0 & \\ cos\phi & -sin\phi & 0 \\ sin\phi & cos\phi & 0 \end{bmatrix} \\ rotateY(\phi)=\begin{bmatrix} cos\phi & 0 & sin\phi \\ 0 & 1 & 0 \\ -sin\phi & 0 & cos\phi \end{bmatrix}

shear

shearX(dy,dz)=[1dydz010001] shearX(d_y, d_z) = \begin{bmatrix} 1 & d_y & d_z \\ 0 & 1 & 0 \\ 0 & 0 & 1 \end{bmatrix}

6.2.1 Arbitrary 3D Rotation

绕任意向量旋转,可以首先将以该向量建立一个基,从该坐标系转换到标准坐标系,利用绕坐标轴旋转完成之后,再利用旋转矩阵的逆矩阵转回来:

[xuxvxwyuyvywzuzvzw][cosϕsinϕ0sinϕcosϕ0001][xuyuzuxvyvzvxwywzw] \begin{bmatrix} x_u & x_v & x_w \\ y_u & y_v & y_w \\ z_u & z_v & z_w \end{bmatrix}\begin{bmatrix} cos\phi & -sin\phi & 0 \\ sin\phi & cos\phi & 0 \\ 0 & 0 & 1 \end{bmatrix}\begin{bmatrix} x_u & y_u & z_u \\ x_v & y_v & z_v \\ x_w & y_w & z_w \end{bmatrix}

If we have a rotation matrix and we wish to have the rotation in axis-angle form, we can compute the one real eigenvalue (which will be λ = 1), and the corresponding eigenvector is the axis of rotation. This is the one axis that is not changed by the rotation.

6.2.2 Transforming Normal Vectors

法线向量的变换不能直接用顶点转换矩阵M进行转换

Chapter 6 Transformation Matrices

设法线为n,切线为t,法线转化矩阵为N。

首先有

nTt=0 n^{T}t = 0

那么经过转换之后法线和切线也仍然垂直,所以有

nNTtM=0   (61) n^{T}_Nt_M = 0 \ \ \ (6-1)

推导

nTt=nTIt=nTM1Mt=0(nTM1)tM=0 n^Tt=n^TIt=n^TM^{-1}Mt=0 \\ (n^TM^{-1})t_M=0\\

根据6-1,可得

nNT=nTM1nN=(nTM1)T=(M1)Tn n^{T}_N = n^TM^{-1} \\ n_N = (n^TM^{-1})^{T} = (M^{-1})^{T}n

所以法线转换矩阵为(M1)T(M^{-1})^{T}

6.3 Translation and Affine Transformations