03 Transformation

91 阅读1分钟

Why study transformation

  • modeling
  • viewing

2D transformation

matrices

Scale

Snipaste_2024-02-14_14-24-28.png

Snipaste_2024-02-14_14-25-36.png 在缩放矩阵中,sx,sys_x,s_y分别代表x,y轴上的缩放倍数(可以不相等)

Reflection

Snipaste_2024-02-14_14-39-14.png 此时sx=1,sy=1s_x=-1,s_y=1

Shear

Snipaste_2024-02-14_14-39-41.png 我们可以看到,在竖直方向上,没有变化,只有在水平方向上有变换
y==0:shift==0;y==1:shift==ay==0:shift==0;y==1:shift==a变换大小随着y的位置而线性变换shift=ayshift=a\cdot y

Rotate:

Snipaste_2024-02-14_14-39-56.png 旋转时,默认以原点为中心进行旋转,那么以任意点c为中心旋转时,怎么办呢?

Snipaste_2024-02-14_14-48-03.png

  1. translate center to origin
  2. rotate
  3. translate back

即先将中心点平移至原点,再进行旋转,之后再平移回原位置

Matrix representation:

T(c)R(α)T(c)T(c)\cdot R({\alpha})\cdot T(-c),矩阵从右向左进行运算

Homogeneous coordinates

Why homogenous coordinates && Translation

Translation:

当我们进行平移时,我们发现不能用矩阵进行表示,即不能用线性变换进行表示,xnew=x+tx,ynes=y+tyx_{new}=x+t_x,y_{nes}=y+t_y 因此我们思考运用仿射变换对包含平移的变换进行描述

仿射变换:

仿射变换(Affine transformation),又称仿射映射,是指在几何中,对一个向量空间进行一次线性变换并接上一个平移,变换为另一个向量空间。

homogenous coordinates

2Dpoints=(x,y,1)2 D points=(x,y,1)
2Dvector=(x,y,0)2 D vector=(x,y,0)
新增的维数用于表示平移,原先的维数用于表示变换

平移矩阵:

[10tx01ty001]{\begin{bmatrix} 1 & 0 & t_x \\ 0 & 1 & t_y \\ 0 & 0 & 1 \end{bmatrix}}

composite transform:

矩阵的乘法不可交换(即乘积顺序不同,结果不同),对于仿射变换矩阵来讲,他是先变换再平移