文章目录
平移矩阵
假设延x轴平移 t x t_x tx,延y轴平移 t y t_y ty距离,显然:
x ′ = x + t x x' = x + t_x x′=x+tx
y ′ = y + t y y' = y + t_y y′=y+ty
用齐次坐标矩阵表示为:
[ x ′ y ′ 1 ] = [ 1 0 t x 0 1 t y 0 0 1 ] ∗ [ x y 1 ] \left[\begin{matrix} x' \\ y' \\ 1 \\ \end{matrix}\right] = \left[\begin{matrix} 1 & 0 & t_x \\ 0 & 1 & t_y \\ 0 & 0 & 1 \\ \end{matrix}\right] * \left[\begin{matrix} x \\ y \\ 1 \\ \end{matrix}\right] ⎣⎡x′y′1⎦⎤=⎣⎡100010txty1⎦⎤∗⎣⎡xy1⎦⎤
所以,平移矩阵:
T ( t x , t y ) = [ 1 0 t x 0 1 t y 0 0 1 ] T(t_x, t_y) = \left[\begin{matrix} 1 & 0 & t_x \\ 0 & 1 & t_y \\ 0 & 0 & 1 \\ \end{matrix}\right] T(tx,ty)=⎣⎡100010txty1⎦⎤
基本旋转矩阵(绕原点)
r 为 op 线段的长度
显然,有三角关系:
x ′ = r ∗ c o s ( θ + α ) = r ∗ c o s θ ∗ c o s α − r ∗ s i n θ ∗ s i n α x' = r * cos(\theta + \alpha) = r * cos\theta * cos\alpha - r * sin\theta * sin\alpha x′=r∗cos(θ+α)=r∗cosθ∗cosα−r∗sinθ∗sinα
y ′ = r ∗ s i n ( θ + α ) = r ∗ s i n θ ∗ c o s α + r ∗ c o s θ ∗ c o s