|
|
| (未显示同一用户的24个中间版本) |
| 第1行: |
第1行: |
| == 通用公式 == | | == 引言 == |
| | | 在使用 css 样式进行样式的缩放、旋转等设置时,思考了一下它的较浅层的原理,恩,这个阶段都是一些初高的数学计算,从新看这里的时候顺便捡了捡初高中的数学,比如三角函数之类。 |
| <math>
| |
| \overset{A matrix}{\begin{bmatrix}
| |
| m \times n
| |
| \end{bmatrix}}
| |
| \times
| |
| \overset{B matrix}{\begin{bmatrix}
| |
| 1 \times n
| |
| \end{bmatrix}}
| |
| = \overset{Y matrix}{\begin{bmatrix}
| |
| 1 \times m
| |
| \end{bmatrix}}
| |
| </math>
| |
| | |
| | |
| 假设 <math>A * B = Y</math>。其中,A 为 <math>m * n</math> 的 m 行 n 列矩阵,B 为 <math>1 * n</math> 列的矩阵。B 拆分为<code>列向量</code>,并且列向量的<code>维数</code>就是矩阵的<code>行数</code>。
| |
| | |
| {{Warning|矩阵列数必须等于向量的维数么?eq: <math>\begin{bmatrix}
| |
| 1 & 2 & 3 & 4 \\
| |
| a & b & c & d \\
| |
| \end{bmatrix} \times \begin{bmatrix}
| |
| 1 \\
| |
| 2 \\
| |
| 3 \\
| |
| 4 \\
| |
| \end{bmatrix}</math>}}
| |
| | |
| == 方法 ==
| |
| transform(a, b, c, d, e, f) 与 Matrix 的转换。
| |
| | |
| <math>\begin{bmatrix}
| |
| x_{ 1 } \\
| |
| y_{ 1 } \\
| |
| 1 \\
| |
| \end{bmatrix} = \begin{bmatrix}
| |
| a & c & e \\
| |
| b & d & f \\
| |
| 0 & 0 & 1 \\
| |
| \end{bmatrix} \times \begin{bmatrix}
| |
| x \\
| |
| y \\
| |
| 1 \\
| |
| \end{bmatrix}</math>
| |
| | |
| 推导出来
| |
| | |
| <math>\begin{cases}
| |
| x_{ 1 } = a \times x + c \times y + 1 \times e \\
| |
| y_{ 1 } = b \times x + d \times y + 1 \times f \\
| |
| 1 = 0 \times 0 + 0 \times 0 + 1 \times 1 \\
| |
| \end{cases}</math>
| |
| | |
| 简化后
| |
| | |
| <math>\begin{cases}
| |
| x_{ 1 } = a \times x + c \times y + e \\
| |
| y_{ 1 } = b \times x + d \times y + f \\
| |
| \end{cases}</math>
| |
|
| |
|
| == 状态 == | | == 状态 == |
| === 缩放 === | | == 齐次坐标系 == |
| | |
| <math>\begin{bmatrix}
| |
| x_{ 1 } \\
| |
| y_{ 1 } \\
| |
| 1 \\
| |
| \end{bmatrix} = \begin{bmatrix}
| |
| a & 0 & 0 \\
| |
| 0 & d & 0 \\
| |
| 0 & 0 & 1 \\
| |
| \end{bmatrix} \times \begin{bmatrix}
| |
| x \\
| |
| y \\
| |
| 1 \\
| |
| \end{bmatrix}</math>
| |
| | |
| 推导出来
| |
| | |
| <math>\begin{cases}
| |
| x_{ 1 } = a \times x \\
| |
| y_{ 1 } = d \times y \\
| |
| \end{cases}</math>
| |
| | |
| === 平移 ===
| |
| | |
| <math>\begin{bmatrix}
| |
| x_{ 1 } \\
| |
| y_{ 1 } \\
| |
| 1 \\
| |
| \end{bmatrix} = \begin{bmatrix}
| |
| 1 & 0 & e \\
| |
| 0 & 1 & f \\
| |
| 0 & 0 & 1 \\
| |
| \end{bmatrix} \times \begin{bmatrix}
| |
| x \\
| |
| y \\
| |
| 1 \\
| |
| \end{bmatrix}</math>
| |
| | |
| 推导出来
| |
| | |
| <math>\begin{cases}
| |
| x_{ 1 } = e + x \\
| |
| y_{ 1 } = f + y \\
| |
| \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} - a}{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>
| |