数学/草稿-1:修订间差异

来自康健生活
Kangkk​(留言 | 贡献)
Kangkk​(留言 | 贡献)
 
(未显示同一用户的31个中间版本)
第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>
 
简要图示:
 
[[文件:Transform-平移.png|500px|无|Transform-平移]]
 
初中数学: