查看“︁数学/草稿-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> ==== scale ==== <syntaxhighlight lang="css"> .box { transform: scale(0.3, 0.6); }</syntaxhighlight> 通过公式计算 <math>\begin{bmatrix} 0.3 & 0 & 0 \\ 0 & 0.6 & 0 \\ 0 & 0 & 1 \\ \end{bmatrix} \times \begin{bmatrix} 1 \\ 1 \\ 1 \\ \end{bmatrix}</math> 等价于 <syntaxhighlight lang="css"> .box { transform: matrix(0.3, 0, 0, 0.6, 0, 0); }</syntaxhighlight> [[文件:Matrix-缩放-1.png|400px|无|matrix-缩放-1]] === 平移 === <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> === 组合 === <syntaxhighlight lang="css"> .box { transform: rotate(30deg) scale(0.3, 0.6); }</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} 0.3 & 0 & 0 \\ 0 & 0.6 & 0 \\ 0 & 0 & 1 \\ \end{bmatrix} = \begin{bmatrix} 0.258 & -0.3 & 0 \\ 0.15 & 0.516 & 0 \\ 0 & 0 & 1 \\ \end{bmatrix}</math> 等价于 <syntaxhighlight lang="css"> .box { transform: matrix(0.258, 0.15, -0.3, 0.516, 0, 0); }</syntaxhighlight> [[文件:Matrix-组合计算-1.png|400px|无|matrix-组合计算-1]] == 齐次坐标系 ==
返回
数学/草稿-1
。
导航菜单
康健生活
搜索
user-page
通知
user-interface-preferences
个人工具
登录
五一
多读书,多运动,多到远处走走,再看看不一样的世界。