得鹿梦鱼 得鹿梦鱼

几何变换_三维

三维几何变换的方法是在二维方法的基础上考虑了z坐标而得到,
平移可以通过指定一个表示对象在三个坐标方向移动距离的三维变换向量来对对象进行平移变换
缩放可以通过指定一个表示对象在三个坐标方向缩放系统的三维变换向量来对对象进行缩放变换
在三维空间中,可能选择空间中的任意方向作为旋转轴的方向,大多数图形软件将三维旋转作为绕三个坐标轴的二维旋转的复合而进行处理,还有一种是用户根据给定的轴的方向和旋转角度建立一个总的旋转矩阵

平移

[xyz1]=[100Tx010Ty001Tz0001][xyz1] = {x=x+Txy=x+Tyz=x+Tz\begin{bmatrix}x' \\y' \\z' \\1\end{bmatrix}\text{=}\begin{bmatrix}1 & 0 & 0 & T_x \\0 & 1 & 0 & T_y \\0 & 0 & 1 & T_z \\0 & 0 & 0 & 1\end{bmatrix}\begin{bmatrix}x \\y \\z \\1\end{bmatrix}\text{ = }\begin{cases}x' = x + T_x \\y' = x + T_y \\z' = x + T_z\end{cases}

缩放

[xyz1]=[sx0000sy0000sz00001][xyz1]={x=xsxy=xsyz=xsz\begin{bmatrix}x' \\y' \\z' \\1\end{bmatrix}\text{=}\begin{bmatrix}s_x & 0 & 0 & 0 \\0 & s_y & 0 & 0 \\0 & 0 & s_z & 0 \\0 & 0 & 0 & 1 \\\end{bmatrix}\begin{bmatrix}x \\y \\z \\1\end{bmatrix}\text{=}\begin{cases}x' = x * s_x \\y' = x * s_y \\z' = x * s_z\end{cases}

旋转

x轴

[xyz1]=[10000cosθsinθ00sinθcosθ00001][xyz1]={x=xy=ycosθzsinθz=ysinθ+zcosθ\begin{bmatrix}x' \\y' \\z' \\1\end{bmatrix}\text{=}\begin{bmatrix}1 & 0 & 0 & 0 \\0 & \cos\theta & -\sin\theta & 0 \\0 & \sin\theta & \cos\theta & 0 \\0 & 0 & 0 & 1 \\\end{bmatrix}\begin{bmatrix}x \\y \\z \\1\end{bmatrix}\text{=}\begin{cases}x' = x \\y' = y * \cos\theta - z * \sin\theta \\z' = y * \sin\theta + z * \cos\theta\end{cases}

y轴

[xyz1]=[cosθ0sinθ00100sinθ0cosθ00001][xyz1]={x=xcosθ+zsinθy=yz=xsinθ+zcosθ\begin{bmatrix}x' \\y' \\z' \\1\end{bmatrix}\text{=}\begin{bmatrix}\cos\theta & 0 & \sin\theta & 0 \\0 & 1 & 0 & 0 \\-\sin\theta & 0 & \cos\theta & 0 \\0 & 0 & 0 & 1 \\\end{bmatrix}\begin{bmatrix}x \\y \\z \\1\end{bmatrix}\text{=}\begin{cases}x' = x * \cos\theta + z * \sin\theta\\y' = y \\z' = -x * \sin\theta + z * \cos\theta\end{cases}

z轴

[xyz1]=[cosθsinθ00sinθcosθ0000100001][xyz1]={x=xcosθysinθy=xsinθ+ycosθz=z\begin{bmatrix}x' \\y' \\z' \\1\end{bmatrix}\text{=}\begin{bmatrix}\cos\theta & -\sin\theta & 0 & 0 \\\sin\theta & \cos\theta & 0 & 0 \\0 & 0 & 1 & 0 \\0 & 0 & 0 & 1 \\\end{bmatrix}\begin{bmatrix}x \\y \\z \\1\end{bmatrix}\text{=}\begin{cases}x' = x * \cos\theta - y * \sin\theta \\y' = x * \sin\theta + y * \cos\theta \\z' = z\end{cases}

一般三维旋转

  1. 平移对象使其与旋转轴通过坐标原点
  2. 旋转对象是的旋转轴与某一坐标轴重合
  3. 绕坐标轴完成指定的旋转
  4. 利用逆旋转使旋转轴回到其原始方向
  5. 利用逆平移使旋转轴回到原始位置

其他三维变换

反射

右手系转到左手系

[1000010000100001]\begin{bmatrix}1 & 0 & 0 & 0 \\0 & 1 & 0 & 0 \\0 & 0 & -1 & 0 \\0 & 0 & 0 & 1 \\\end{bmatrix}

错切

z轴错切

[10shzxshzxZref01shzyshzyZref00100001]\begin{bmatrix}1 & 0 &sh_{zx} & -sh_{zx} \cdot Z_{ref} \\0 & 1 &sh_{zy} & -sh_{zy} \cdot Z_{ref} \\0 & 0 & 1 & 0 \\0 & 0 & 0 & 1 \\\end{bmatrix}

仿射变换

如果坐标变换的形式是

{x=axxx+axyy+axzz+bxy=ayxx+ayyy+ayzz+byx=azxx+azyy+azzz+bz\begin{cases}x' = a_{xx}x + a_{xy}y + a_{xz}z + b_x \\y' = a_{yx}x + a_{yy}y + a_{yz}z + b_y \\x' = a_{zx}x + a_{zy}y + a_{zz}z + b_z \\\end{cases}
则该变换称为放射变换,每一个变换后的坐标是是原坐标的线性函数,且常数是变换类型确定的常数