|
|
| 第136行: |
第136行: |
| y_{ 1 } = f + y \\ | | y_{ 1 } = f + y \\ |
| \end{cases}</math> | | \end{cases}</math> |
|
| |
| === 旋转 ===
| |
| <math>\theta</math> 定义为弧度,并定义 <math>\beta</math> 为角度。则 <math>\theta</math> 值为 <math>\theta = \frac{\pi \times 180}{\beta}</math>
| |
|
| |
| <math>\begin{bmatrix}
| |
| x_{ 1 } \\
| |
| y_{ 1 } \\
| |
| 1 \\
| |
| \end{bmatrix} = \begin{bmatrix}
| |
| \cos{\theta} & -\sin{\theta} & 0 \\
| |
| \sin{\theta} & \cos{\theta} & 0 \\
| |
| 0 & 0 & 1 \\
| |
| \end{bmatrix} \times \begin{bmatrix}
| |
| x \\
| |
| y \\
| |
| 1 \\
| |
| \end{bmatrix}</math>
| |
|
| |
| 推导出来
| |
|
| |
| <math>\begin{cases}
| |
| x_{ 1 } = \cos{\theta} \times x - \sin{\theta} \times y \\
| |
| y_{ 1 } = \sin{\theta} \times x + \cos{\theta} \times y \\
| |
| \end{cases}</math>
| |
|
| |
| ==== 假设 ====
| |
| 假设存在点 E 移动至点 F。设 E 坐标为(x1, y1),F 坐标为(x2, y2),D 坐标为(a, b)。
| |
|
| |
| 简要图示:
| |
|
| |
| [[文件:Transform-平移.png|500px|无|Transform-平移]]
| |
|
| |
| 初中数学:
| |
|
| |
| <math>\begin{cases}
| |
| \cos\beta = \frac{x_{1} - a}{r} \\
| |
| \sin\beta = \frac{y_{1} - b}{r} \\
| |
| \cos\gamma = \frac{x_{2} - a}{r} \\
| |
| \sin\gamma = \frac{y_{2} - b}{r} \\
| |
|
| |
| \end{cases}</math>
| |
|
| |
| 演算:
| |
|
| |
| <math>\begin{cases}
| |
| \cos\beta = \frac{x_{1} - a}{r} \\
| |
| \sin\beta = \frac{y_{1} - a}{r} \\
| |
| x_{2} - a = \cos\gamma \times r = \cos(\beta - \alpha) \times r = (\cos\alpha \times \cos\beta + \sin\beta \times \sin\alpha) \times r \\
| |
| y_{2} - b = \sin\gamma \times r = \sin(\beta - \alpha) \times r = (\sin\beta \times \cos\alpha - \sin\alpha \times \cos\beta) \times r \\
| |
| \end{cases}</math>
| |
|
| |
| 推导:
| |
|
| |
| <math>\begin{cases}
| |
| a = 0 \\
| |
| b = 0 \\
| |
| x_{2} = \cos\alpha \times (x_{1} - a) + \sin\alpha \times (y_{1} - b) + a = \cos\alpha \times x_{1} + \sin\alpha \times y_{1} \\
| |
| y_{2} = \cos\alpha \times (y_{1} - b) - \sin\alpha \times (x_{1} - a) +b = \cos\alpha \times y_{1} - \sin\alpha \times x_{1} \\
| |
| \end{cases}</math>
| |
|
| |
| 点旋转的角度 <math>\alpha</math> 是正旋转还是负旋转,当角度是负旋转时 <math>\theta = -\alpha</math>。
| |
|
| |
| 验证:
| |
|
| |
| <math>\begin{cases}
| |
| \cos\beta = \frac{x_{1} - a}{r} \\
| |
| \sin\beta = \frac{y_{1} - a}{r} \\
| |
| x_{2} = \cos(\beta - (-\theta)) \times r = (\cos\beta \times \cos\theta - \sin\beta \times \sin\theta) \times r = \cos\theta \times x_{1} - \sin\theta \times y_{1} \\
| |
| y_{2} = \sin(\beta - (-\theta)) \times r = (\sin\theta \times \cos\beta + \sin\beta \times \cos\theta) \times r = \cos\theta \times y_{1} + \sin\theta \times x_{1} \\
| |
| \end{cases}</math>
| |
|
| |
| 转换为矩阵:
| |
|
| |
| <math>\begin{bmatrix}
| |
| x_{2} \\
| |
| y_{2} \\
| |
| \end{bmatrix} = \begin{bmatrix}
| |
| \cos\theta & -\sin\theta \\
| |
| \cos\theta & \sin\theta \\
| |
| \end{bmatrix} \times \begin{bmatrix}
| |
| x_{1} \\
| |
| y_{1} \\
| |
| \end{bmatrix}</math>
| |
|
| |
| ==== rotate ====
| |
| 从 css 语法上开始转换
| |
| <syntaxhighlight lang="css">
| |
| .box {
| |
| transform: rotate(30deg);
| |
| }</syntaxhighlight>
| |
|
| |
| 这个旋转套用公式
| |
|
| |
| <math>\begin{bmatrix}
| |
| \cos{30^\circ} & -\sin{30^\circ} & 0 \\
| |
| \sin{30^\circ} & \cos{30^\circ} & 0 \\
| |
| 0 & 0 & 1 \\
| |
| \end{bmatrix} \times \begin{bmatrix}
| |
| 1 \\
| |
| 1 \\
| |
| 1 \\
| |
| \end{bmatrix}</math>
| |
|
| |
| 等价于
| |
|
| |
| <syntaxhighlight lang="css">
| |
| .box {
| |
| transform: matrix(0.86, 0.5, -0.5, 0.86, 0, 0);
| |
| }</syntaxhighlight>
| |
|
| |
| [[文件:Matrix-旋转-1.png|400px|无|matrix-旋转-1]]
| |
|
| |
|
| === 组合 === | | === 组合 === |