几何变换的基本原理

旋转变换使对象绕x,y或z轴旋转,逆时针旋转时角度为正。如果旋转角度为θ,则下面的矩阵定义绕各轴的旋转。

\[\left[ \begin{matrix} 1 & 0 & 0 & 0 \\ 0 & \operatorname{cos}{{\theta}_{x}} & -\operatorname{sin}{{\theta}_{x}} & 0 \\ 0 & \operatorname{sin}{{\theta}_{x}} & \operatorname{cos}{{\theta}_{x}} & 0 \\ 0 & 0 & 0 & 1 \end{matrix} \right] \left[ \begin{matrix} \operatorname{cos}{{\theta}_{y}} & 0 & \operatorname{sin}{{\theta}_{y}} & 0 \\ 0 & 1 & 0 & 0 \\ -\operatorname{sin}{{\theta}_{y}} & 0 & \operatorname{cos}{{\theta}_{y}} & 0 \\ 0 & 0 & 0 & 1 \end{matrix} \right] \left[ \begin{matrix} \operatorname{cos}{{\theta}_{z}} & -\operatorname{sin}{{\theta}_{z}} & 0 & 0 \\ \operatorname{sin}{{\theta}_{z}} & \operatorname{cos}{{\theta}_{z}} & 0 & 0 \\ 0 & 0 & 1 & 0 \\ 0 & 0 & 0 & 1 \end{matrix} \right]\]

平移变换相对于当前位置移动对象,用距离tx,ty和tz指定平移。下面的矩阵显示了这些元素在变换矩阵中的位置。

\[\left[ \begin{matrix} 1 & 0 & 0 & {t}_{x} \\ 0 & 1 & 0 & {t}_{y} \\ 0 & 0 & 1 & {t}_{z} \\ 0 & 0 & 0 & 1 \end{matrix} \right]\]

缩放(比例)变换改变对象的大小,指定比例因子sx, sy和sz创建下面的矩阵:

\[\left[ \begin{matrix} {S}_{x} & 0 & 0 & 0 \\ 0 & {S}_{y} & 0 & 0 \\ 0 & 0 & {S}_{z} & 0 \\ 0 & 0 & 0 & 1 \end{matrix} \right]\]

默认变换矩阵是单位矩阵,可以用eye函数创建它。下面是单位矩阵:

\[\left[ \begin{matrix} 1 & 0 & 0 & 0 \\ 0 & 1 & 0 & 0 \\ 0 & 0 & 1 & 0 \\ 0 & 0 & 0 & 1 \end{matrix} \right]\]