Skip to content

坐标变换

平移

[xy]=[xy]+[ab]\begin{bmatrix} x' \\ y' \end{bmatrix} = \begin{bmatrix} x \\ y \end{bmatrix} + \begin{bmatrix} a \\ b \end{bmatrix}

用矩阵乘法也表示为:

[xy1]=[10a01b001][xy1]\begin{bmatrix} x' \\ y' \\ 1 \end{bmatrix} = \begin{bmatrix} 1 & 0 & a \\ 0 & 1 & b \\ 0 & 0 & 1 \end{bmatrix} \begin{bmatrix} x \\ y \\ 1 \end{bmatrix}

旋转

绕原点的旋转,通过几何或复数(eiθze^{i\theta}z)来推导:

[xy1]=[cosθsinθ0sinθcosθ0001][xy1]\begin{bmatrix} x' \\ y' \\ 1 \end{bmatrix} = \begin{bmatrix} \cos\theta & -\sin\theta & 0\\ \sin\theta & \cos\theta & 0\\ 0 & 0 & 1 \end{bmatrix} \begin{bmatrix} x \\ y \\ 1 \end{bmatrix}

一般变换

[xy1]=[10a01b001][cosθsinθ0sinθcosθ0001][xy1]=[cosθsinθasinθcosθb001][xy1]\begin{bmatrix} x' \\ y' \\ 1 \end{bmatrix}= \begin{bmatrix} 1 & 0 & a \\ 0 & 1 & b \\ 0 & 0 & 1 \end{bmatrix} \begin{bmatrix} \cos\theta & -\sin\theta & 0\\ \sin\theta & \cos\theta & 0\\ 0 & 0 & 1 \end{bmatrix} \begin{bmatrix} x \\ y \\ 1 \end{bmatrix} = \begin{bmatrix} \cos\theta & -\sin\theta & a \\ \sin\theta & \cos\theta & b \\ 0 & 0 & 1 \end{bmatrix} \begin{bmatrix} x \\ y \\ 1 \end{bmatrix}

求变换矩阵

只需要两个点的坐标就能知道变换矩阵。

设坐标系 AA 中两点 (x1,y1),(x2,y2)(x_1, y_1), (x_2, y_2), BB 中两点 (x1,y1),(x2,y2)(x_1', y_1'), (x_2', y_2') ,则

[x2x1y2y1]=[cosθsinθsinθcosθ][x2x1y2y1]\begin{bmatrix} x_2 - x_1 \\ y_2 - y_1 \end{bmatrix} = \begin{bmatrix} \cos\theta & -\sin\theta \\ \sin\theta & \cos\theta \end{bmatrix} \begin{bmatrix} x_2' - x_1' \\ y_2' - y_1' \end{bmatrix}

可解得 θ\theta 。则变换矩阵为:

[cosθsinθx1x1sinθcosθy1y1001]\begin{bmatrix} \cos\theta & -\sin\theta & x_1 - x_1' \\ \sin\theta & \cos\theta & y_1 - y_1' \\ 0 & 0 & 1 \end{bmatrix}