视频加载失败

Transformation 变换

212 字
1 分钟
Transformation 变换
Transformation 变换

Transformation 变换#

Scale Matrix 缩放#

  • 本质单位向量变换 [x′y′]=[sx00sy][xy]\begin{bmatrix} x'\\y'\end{bmatrix}=\begin{bmatrix} s_x&0\\0&s_y\end{bmatrix}\begin{bmatrix} x\\y\end{bmatrix}

Reflection Matrix: sxorsy=−1s_x or s_y=-1

Shear Matrix 伸缩#

  • 本质单位向量变换 [x′y′]=[1a01][xy]\begin{bmatrix} x'\\y'\end{bmatrix}=\begin{bmatrix} 1&a\\0&1\end{bmatrix}\begin{bmatrix} x\\y\end{bmatrix}
  • xx方向单位向量不变,yy方向单位向量变为[a1]T\begin{bmatrix}a & 1 \end{bmatrix}^T
  • 绕原点旋转

Rotate Matrix 旋转#

  • 本质单位向量变换 [x′y′]=[cosθ−sinθsinθcosθ][xy]\begin{bmatrix} x'\\y' \end{bmatrix}=\begin{bmatrix} cos\theta&-sin\theta\\sin\theta&cos\theta \end{bmatrix}\begin{bmatrix} x\\y \end{bmatrix}

Linear Transforms 线性变换#

x′=ax+byy′=cx+dyx'=ax+by \qquad y'=cx+dy

[x′y′]=[acbd][xy]\begin{bmatrix} x'\\y' \end{bmatrix}=\begin{bmatrix} a&c\\b&d \end{bmatrix}\begin{bmatrix} x\\y \end{bmatrix}

齐次坐标下的变换#

  • 2D point: [x,y,1]T\begin{bmatrix} x,y,1 \end{bmatrix}^T

  • 2D vector: [x,y,0]T\begin{bmatrix} x,y,0 \end{bmatrix}^T

  • [x,y,w]\begin{bmatrix} x,y,w \end{bmatrix} 即是2D点: [xw,yw,1](w≠0)\begin{bmatrix} \frac{x}{w},\frac{y}{w},1 \end{bmatrix}(w\neq0)

Scale 缩放#

S(sx,sy)=[sx000sy0001]S(s_x,s_y)=\begin{bmatrix} s_x&0&0\\0&s_y&0\\0&0&1 \end{bmatrix}

Rotation 旋转#

R(α)=[cosθ−sinθ0sinθcosθ0001]R(\alpha)=\begin{bmatrix} cos\theta&-sin\theta&0\\sin\theta&cos\theta&0\\0&0&1 \end{bmatrix}

Translation 平移#

T(tx,ty)=[10tx01ty001]T(t_x,t_y)=\begin{bmatrix} 1&0&t_x\\0&1&t_y\\0&0&1 \end{bmatrix}

Composite Transform#

  • R⋅T≠T⋅RR\cdot T \neq T\cdot R
  • 对于变换:An(...A2(A1(x)))=An...A2⋅A1[xy1]A_n(...A_2(A_1(x))) = A_n...A_2\cdot A_1\begin{bmatrix} x\\y\\1 \end{bmatrix},从右往左依次应用于向量

复杂变换的分解:以绕某点c为例#

变换矩阵M=T(−c)R(α)T(c)M=T(-c)R(\alpha)T(c)(先平移回原点,旋转,然后再平移回c点)

因为旋转矩阵是相对于原点的

文章分享

如果这篇文章对你有帮助,欢迎分享给更多人!

Profile Image of the Author
机巧叶片
给互联网留下一点微小的贡献
公告
欢迎来到我的博客!这是一则示例公告。
分类
标签
最新动态
站点统计
文章
26
分类
6
标签
22
总字数
27,977
运行时长
0 天
最后活动
0 天前
站点信息
构建平台
Cloudflare Pages
博客版本
Firefly v6.16.8
文章许可
CC BY-NC-SA 4.0
文章目录