计算机图形学——第九章

三维几何变换

三维几何变换是在二维几何变换的基础上扩充了z坐标得到的

一、基础的几何变换

1、平移

任意点P=(x, y, z) 通过平移t_{x}t_{y}t_{z}加到P的坐标上而平移到位置P' = (x', y' ,z')

x' = x + t_{x}    y' = y + t_{y}   z' = z + t_{z} 

用矩阵表示: \begin{bmatrix}1 && 0 && 0 &&t_{x} \\0 &&1 && 0 &&t_{y}\\0 && 0 && 1 &&t_{z}\\0 && 0 && 0 &&1 \end{bmatrix} \cdot \ \begin{bmatrix}x \\y\\z\\1 \end{bmatrix}

2、旋转

绕z轴旋转 :  \begin{bmatrix}\cos \theta   && -\sin \theta && 0 &&0 \\\sin \theta &&\cos \theta && 0 &&0\\0 && 0 && 1 &&0\\0 && 0 && 0 &&1 \end{bmatrix} \cdot \ \begin{bmatrix}x \\y\\z\\1 \end{bmatrix}


绕x轴旋转: \begin{bmatrix}1   && 0 && 0 &&0 \\0 &&\cos \theta && -\sin \theta &&0\\0 && \sin \theta && \cos \theta &&0\\0 && 0 && 0 &&1 \end{bmatrix} \cdot \ \begin{bmatrix}x \\y\\z\\1 \end{bmatrix}


绕y轴旋转: \begin{bmatrix}\cos \theta   && 0 && \sin \theta &&0 \\0 &&1&&0 &&0\\-\sin \theta && 0 && \cos \theta &&0\\0 && 0 && 0 &&1 \end{bmatrix} \cdot \ \begin{bmatrix}x \\y\\z\\1 \end{bmatrix}


对于对象绕与坐标轴不一致的轴进行旋转的变换矩阵,可以利用平移加坐标轴旋转复合而成

1、平移对象使其旋转轴与平行于该轴的一个坐标轴重合

2、绕该坐标轴完成指定的旋转

3、平移对象将其旋转轴移回到原来的位置

对于对象绕与每个坐标轴均不平行的轴进行旋转,需要额外的变换

1、平移对象,使得旋转轴通过坐标原点

2、旋转对象使得旋转轴与某一坐标轴重合

3、绕该坐标轴完成指定的旋转

4、利用逆旋转使旋转轴回到其原始位置

5、利用逆平移使旋转轴回到其原始位置


缩放:

相对原点的缩放 \begin{bmatrix}s_{x} && 0 && 0 &&0 \\0 &&s_{y} && 0 &&0\\0 && 0 && s_{z} &&0\\0 && 0 && 0 &&1 \end{bmatrix} \cdot \ \begin{bmatrix}x \\y\\z\\1 \end{bmatrix}

对于指定点(x_{f}, y_{f},z_{f})的缩放变换

1、平移给定点到原点

2、使用缩放公式,相对原点缩放对象

3、平移给定点回到原始位置

 \begin{bmatrix}s_{x} && 0 && 0 &&(1-s_{x})x_{f} \\0 &&s_{y} && 0 &&(1-s_{y})y_{f}\\0 && 0 && s_{z} &&(1-s_{z})z_{f}\\0 && 0 && 0 &&1 \end{bmatrix}

二、其他的三维变换

三维反射

相对于给定的反射轴,或者对于给定的反射平面

相对于xy平面的点反射矩阵 \begin{bmatrix}1 && 0 && 0 &&0 \\0 &&1 && 0 &&0\\0 && 0 && -1 &&0\\0 && 0 && 0 &&1 \end{bmatrix}

三维错切

相对于z轴的错切 \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’ = a_{xx}x+a_{xy}y+a_{xz}z+b_{x}

y‘  = a_{yx}x+a_{yy}y+a_{yz}z+b_{y}

z’  = a_{zx}x+a_{zy}y+a_{zz}z+b_{z}

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容