📜  计算机图形学– 3D剪切转换

📅  最后修改于: 2021-08-25 17:27:39             🧑  作者: Mango

剪切变换与我们在2D空间中看到的相同,但是这里我们必须处理x,y和z轴,而在2D中我们仅处理x和y轴。剪切是在3D空间中沿x,y或z方向倾斜对象的过程。剪切会改变(或变形)对象的形状。当我们讨论3D空间时,也可以在以下三个方向中的任何一个上进行剪切。下面给出的是剪切变换的类型。

  • 在X方向上剪切。
  • y方向的剪切
  • 在z方向上剪切。

X方向的剪切:此处的X坐标保持不变,而Y和Z的坐标发生变化。剪切是通过剪切转换矩阵完成的,其表示如下。

\hspace{6.08cm} \mathbf{S_x=\left [\begin{matrix}1&s_y&s_z&0\\0&1&0&0 \\0&0&1&0\\0&0&0&1\end{matrix}\right] }

考虑3D空间中的点P [x,y,z],在该点上我们在X方向上执行剪切变换,并变为P'[x,y,z]。

\mathbf{P'[x\hspace{0.2cm}y \hspace{0.2cm}z\hspace{0.2cm}1]= P[x_o\hspace{0.2cm}y_o\hspace{0.2cm}z_o\hspace {0.2cm}1].S_x}\\ \newline \hspace {6.08cm}\mathbf{P'[x, \hspace{0.2cm}y, \hspace{0.2cm}z]=[x_o, \hspace{0.2cm}y_n, \hspace{0.2cm}z_n]} \\

\textbf{The coordinate}\, \, \mathbf{P'[x_n, y_n, z_n]}\, \, \textbf{can also be calculated using below equations:} \newline \hspace{6.8cm}\mathbf{x_n = x_o \hspace{0.4cm}Remains\hspace{0.2cm}unchanged} \\ \hspace{6.8cm}\mathbf{y_n=y_o+s_y.x_o} \\ \hspace{6.8cm}\mathbf{z_n=z_o+s_z.x_0}\\

Y方向的剪切:此处的Y坐标保持不变,而X和Z的坐标发生变化。剪切是通过剪切转换矩阵完成的,其表示如下。

\mathbf{S_y= \left [\begin{matrix}1&0&0&0\\s_x&1&s_z&0 \\0&0&1&0\\0&0&0&1\end{matrix}\right] }

考虑3D空间中的一个点P [x,y,z],在该点上我们在Y方向上执行剪切变换,它变为P'[x,y,z]。

\mathbf{P'[x\hspace{0.2cm}y \hspace{0.2cm}z\hspace{0.2cm}1]=P[x_o\hspace {0.2cm}y_o\hspace{0.2cm}z_o\hspace{0.2cm}1].S_y} \\ \newline \hspace{6.08cm}\mathbf{P'[x, \hspace{0.2cm}y, \hspace{0.2cm}z]=[x_n, \hspace{0.2cm}y_o, \hspace{0.2cm}z_n]} \\ \newline

\textbf{The coordinate}\, \, \mathbf{P'[x_n, y_n, z_n]}\, \, \textbf{can also be calculated using below equations:} \newline \hspace{6.8cm}\mathbf{x_n = x_o+s_x.y_o   } \\ \hspace{6.8cm}\mathbf{y_n=y_o \hspace{0.4cm}Remains \hspace{0.2cm}unchanged}\\ \hspace{6.8cm} \mathbf{z_n=z_o+s_z.y_o }\\

Z方向的剪切:此处的Z坐标保持不变,而X和Y的坐标发生变化。剪切是通过剪切转换矩阵完成的,对于Z方向的剪切,其表示如下。

\mathbf{S_z =\left [\begin{matrix}1&0&0&0 \\0&1&0&0\\s_x&s_y&1&0 \\0&0&0&1\end{matrix}\right] }

考虑3D空间中的一个点P [x,y,z],在该点上我们在Z方向上执行剪切变换,并变成P'[x,y,z]。

\mathbf{P'[x\hspace{0.2cm} y\hspace{0.2cm}z\hspace{0.2cm}1]=P[x_o \hspace{0.2cm}y_o\hspace{0.2cm}z_o\hspace {0.2cm}1].S_z}\\ \newline \hspace{6.08cm} \mathbf{P'[x, \hspace{0.2cm}y, \hspace{0.2cm}z]=[x_n, \hspace{0.2cm}y_n, \hspace{0.2cm}z_o]}\\

\textbf{The coordinate}\, \, \mathbf{P'[x_n, y_n, z_n]}\, \, \textbf{can also be calculated using below equations:} \newline \hspace{6.8cm}\mathbf{x_n = x_o+s_x.z_o   } \\ \hspace{6.8cm}\mathbf{y_n=y_o+s_y.z_o} \\ \hspace{6.8cm}\mathbf{z_n=z_o \hspace{0.4cm}Remains \hspace{0.2cm}unchanged}\\

注意:此处,x n ,y n ,z n显示=新值,x o ,y o ,z o显示=旧值。

如果剪切参数如下S x = 2,S y = 3,则在给定的长方体(OABCDEFG)上沿Z方向执行剪切变换。

z方向的剪切变形矩阵如下。

\mathbf{S_z=\left [\begin{matrix}1&0&0&0\\0&1&0&0\\s_x&s_y&1&0 \\0&0&0&1\end{matrix}\right]}

给定的长方体如下:

图。1

现在,我们将剪切转换条件应用于所有坐标,并计算新的对应坐标:

执行反射变换后,点O [0,0,0]变为O’:

\mathbf {O'[x\hspace{0.2cm}y\hspace {0.2cm}z\hspace{0.2cm}1]= [0\hspace{0.2cm}0\hspace{0.2cm}0 \hspace{0.2cm}1]\left [\begin{matrix}1&0&0&0 \\0&1&0&0\\2&3&1&0\\0&0&0&1 \end{matrix}\right]} \\ \newline \hspace{7.09cm}\mathbf{= [\hspace{0.2cm}0\hspace{0.2cm}0\hspace {0.2cm}0\hspace{0.2cm}1]}\\ \newline \hspace{4.37cm}\mathbf {O'[x\hspace{0.2cm}y\hspace {0.2cm}z\hspace{0.2cm}1]= [\hspace{0.2cm}0\hspace{0.2cm}0 \hspace{0.2cm}0\hspace{0.2cm}1]}

执行反射变换后,点A'[0,0,4]变为A’:

\mathbf{A'[x \hspace {0.2cm}y\hspace{0.2cm}z \hspace{0.2cm}1] = [0\hspace{0.2cm}0\hspace{0.2cm}4 \hspace {0.2cm}1]\left [\begin{matrix} 1&0&0&0 \\0&1&0&0\\2&3&1&0\\0&0&0&1\end {matrix}\right]} \\ \newline \hspace {7.09cm}\mathbf{= [8\hspace{0.2cm}12\hspace {0.2cm}4\hspace{0.2cm}1]} \\ \newline \hspace {4.37cm}\mathbf{A'[x\hspace{0.2cm}, y\hspace{0.2cm}, z]= [8\hspace{0.2cm}12 \hspace{0.2cm}4]}

执行反射变换后,点B'[0,0,4]变为B’:

\mathbf{B' [x\hspace{0.2cm}y\hspace {0.2cm}z\hspace{0.2cm}1]= [0\hspace{0.2cm}4\hspace{0.2cm}2\hspace{0.2cm}1] \left [\begin{matrix}1&0&0&0\\0&1&0&0 \\2&3&1&0\\0&0&0&1\end{matrix}\right]} \\ \newline \hspace{7.09cm}\mathbf{= [8\hspace{0.2cm}10\hspace{0.2cm}2\hspace{0.2cm}1]} \\ \newline \hspace{4.37cm}\mathbf{B'[x\hspace{0.2cm}, y\hspace{0.2cm}, z]=[8\hspace{0.2cm}10\hspace{0.2cm}2]}

执行反射变换后,点C'[2,4,0]变为C’:

\mathbf{C'[x\hspace{0.2cm}y \hspace{0.2cm}z\hspace{0.2cm}1]= [2\hspace{0.2cm}4\hspace{0.2cm}0 \hspace{0.2cm}1]\left [\begin{matrix}1&0&0&0 \\0&1&0&0\\2&3&1&0 \\0&0&0&1\end{matrix}\right]} \\ \newline \hspace {7.09cm}\mathbf{= [2\hspace{0.2cm}4\hspace {0.2cm}0\hspace{0.2cm}1]}\\ \newline \mathbf{C'[x\hspace{0.2cm}, y\hspace{0.2cm}, z]= [2\hspace{0.2cm}4\hspace {0.2cm}0]}

执行反射变换后,点D'[2,2,4]变为D’:

\mathbf{D'[x\hspace{0.2cm}y \hspace{0.2cm}z\hspace{0.2cm}1]= [2\hspace{0.2cm}2\hspace{0.2cm}4\hspace {0.2cm}1]\left [\begin{matrix}1&0&0&0 \\0&1&0&0\\2&3&1&0\\0&0&0&1\end{matrix}\right] } \\ \newline \hspace{7.09cm}\mathbf{= [10\hspace{0.2cm}14\hspace{0.2cm}4\hspace{0.2cm}1] }\\ \newline \hspace{4.37cm}\mathbf{D'[x\hspace{0.2cm} , y\hspace{0.2cm}, z]=[10\hspace{0.2cm}14 \hspace{0.2cm}4]}

执行反射变换后,点E'[2,0,0]变为E’:

\mathbf{E' [x\hspace{0.2cm}y\hspace {0.2cm}z\hspace{0.2cm}1]= [2\hspace{0.2cm}0\hspace {0.2cm}0\hspace{0.2cm}1] \left [\begin{matrix}1&0&0&0 \\0&1&0&0\\2&3&1&0 \\0&0&0&1\end{matrix}\right]} \\ \newline \hspace{7.09cm}\mathbf{= [2\hspace{0.2cm}0\hspace{0.2cm}0\hspace{0.2cm}1]} \\ \newline \hspace{4.37cm}\mathbf{E'[x\hspace{0.2cm}, y\hspace{0.2cm}, z]=[2\hspace{0.2cm}0\hspace{0.2cm}0]}

执行反射变换后,点F'[0,0,2]变为F’:

\mathbf {F'[x\hspace{0.2cm}y\hspace{0.2cm}z \hspace{0.2cm}1]=[0\hspace{0.2cm}0\hspace {0.2cm}2\hspace{0.2cm}1]\left [\begin{matrix}1&0&0&0\\0&1&0&0\\2&3&1&0 \\0&0&0&1\end{matrix}\right]} \\ \newline \hspace{7.09cm}\mathbf{= [4\hspace{0.2cm}6\hspace{0.2cm}2\hspace{0.2cm}1]} \\ \newline \hspace{4.37cm}\mathbf{F'[x\hspace{0.2cm}, y\hspace{0.2cm}, z]=[4\hspace{0.2cm}6\hspace{0.2cm}2]}

执行反射变换后,点G'[2,0,2]变为G’:

\mathbf{G'[x\hspace{0.2cm}y \hspace{0.2cm}z\hspace{0.2cm}1]=[2\hspace{0.2cm}0 \hspace{0.2cm}2\hspace{0.2cm}1]\left [\begin{matrix}1&0&0&0\\0&1&0&0\\2&3&1&0 \\0&0&0&1\end{matrix}\right]} \\ \newline \hspace{7.09cm}\mathbf{= [6\hspace{0.2cm}6\hspace{0.2cm}2\hspace{0.2cm}1]} \\ \newline \hspace{4.37cm}\mathbf {G'[x\hspace{0.2cm}, y\hspace{0.2cm}, z]= [6\hspace{0.2cm}6\hspace{0.2cm}2]}

最后,在对给定的长方体执行剪切变形后,图1将如下所示:

剪切变形

图2