计算机图形学笔记-坐标变换
坐标系
本体坐标系(右):为了描述基本的形体而引入的坐标系
用户坐标系(右):用户引入描述整个形体的坐标系
观察坐标系(左):作为观察姿态而引入,观察者所处的位置,因为Z轴冲着眼睛的方向
设备坐标系:显示器的坐标系
规范化设备坐标系:与具体设备无关的坐标系
X手系,用手从X轴向Y轴转,看看Z轴是否对应拇指即可
变换
\[p^{'}=\left[\begin{matrix}\end{matrix}\right]
\]
平移变换T
\[p^{'}=\left[\begin{matrix}
x^{'}&y^{'}&1
\end{matrix}\right]=\left[\begin{matrix}x&y&1\end{matrix}\right]\left[\begin{matrix}
1&0&0\\
0&1&0\\
T_x&T_y&1\\
\end{matrix}\right]
\]
比例变换S
\[p^{'}=\left[\begin{matrix}
x^{'}&y^{'}&1
\end{matrix}\right]=\left[\begin{matrix}x&y&1\end{matrix}\right]\left[\begin{matrix}
S_x&0&0\\
0&S_y&0\\
0&0&1\\
\end{matrix}\right]
\]
旋转变换R
\[p^{'}=\left[\begin{matrix}
x^{'}&y^{'}&1
\end{matrix}\right]=\left[\begin{matrix}x&y&1\end{matrix}\right]\left[\begin{matrix}
\cos\theta&\sin\theta&0\\
-\sin\theta&\cos\theta&0\\
0&0&1\\
\end{matrix}\right]
\]
按照阅读顺序记忆,cos,sin,-sin,cos
矩阵连乘时要从左向右乘
对称变换
\[p^{'}=\left[\begin{matrix}
x^{'}&y^{'}&1
\end{matrix}\right]=\left[\begin{matrix}x&y&1\end{matrix}\right]\left[\begin{matrix}
a&d&0\\
b&e&0\\
0&0&1\\
\end{matrix}\right]
\]
关于Y=-X对称
\[\left[\begin{matrix}
0&-1&0\\
-1&0&0\\
0&0&1\\
\end{matrix}\right]
\]
错切变换,沿X轴方向关于Y的错切
\[p^{'}=\left[\begin{matrix}
x^{'}&y^{'}&1
\end{matrix}\right]=\left[\begin{matrix}x&y&1\end{matrix}\right]\left[\begin{matrix}
1&0&0\\
b&1&0\\
0&0&1\\
\end{matrix}\right]=\left(\begin{matrix}x+by&y&1\end{matrix}\right)
\]
关于X的错切
\[\left(\begin{matrix}x+by&y&1\end{matrix}\right)
\]
平移、旋转、比例、错切都属于拓扑不变的几何变换。
视见变换
我理解的是游戏是一个窗口,然后屏幕的某块区域用来运行游戏,所以需要现平移到原点,在进行缩放,然后移回去,就是视见变换。
\[H=T_1(-wxl,-wyl)*S(S_x,S_y)*T_2(vxl,vyl)\\
=\left[\begin{matrix}
1&0&0\\
0&1&0\\
-wxl&-wyl&1\\
\end{matrix}\right]\left[\begin{matrix}
\frac{vxh-vxl}{wxh-wxl}&0&0\\
0&\frac{vxh-vxl}{wxh-wxl}&0\\
0&0&1\\
\end{matrix}\right]\left[\begin{matrix}
1&0&0\\
0&1&0\\
vxl&vyl&1\\
\end{matrix}\right]
\]
三维旋转变换
记忆法:绕哪个轴旋转,它的右下一格(如果到达界限就轮转)为起始点,cos sin -sin cos这样就可以了
旋转的逆变换只需要把sin位置的数字取反就行了,cos不变
等轴投影
投影平面的法向量与三个轴的夹角都相等。