OpenGL绘图基本矩阵运算讲解

一、平移矩阵

坐标平移 ( d x , d y , d z ) (dx,dy,dz) (dxdydz)
[ 1 0 0 d x 0 1 0 d y 0 0 1 d z 0 0 0 1 ] \begin{bmatrix} 1 & 0 & 0 & d_x\\ 0 & 1 & 0 & d_y\\ 0 & 0 & 1 & d_z\\ 0 & 0 & 0 & 1 \end{bmatrix} 100001000010dxdydz1
例:
[ 1 0 0 d x 0 1 0 d y 0 0 1 d z 0 0 0 1 ] ⋅ [ x y z 1 ] = [ ( 1 ⋅ x ) + ( 0 ⋅ y ) + ( 0 ⋅ z ) + ( d x ⋅ 1 ) ( 0 ⋅ x ) + ( 1 ⋅ y ) + ( 0 ⋅ z ) + ( d y ⋅ 1 ) ( 0 ⋅ x ) + ( 0 ⋅ y ) + ( 1 ⋅ z ) + ( d z ⋅ 1 ) ( 0 ⋅ x ) + ( 0 ⋅ y ) + ( 0 ⋅ z ) + ( 1 ⋅ 1 ) ] = [ x + d x y + d y z + d z 1 ] \begin{bmatrix} 1 & 0 & 0 & d_x\\ 0 & 1 & 0 & d_y\\ 0 & 0 & 1 & d_z\\ 0 & 0 & 0 & 1 \end{bmatrix} \cdot \begin{bmatrix} x \\ y \\ z \\ 1 \\ \end{bmatrix} = \begin{bmatrix} (1 \cdot x) + (0\cdot y) + (0\cdot z) + ( d_x\cdot 1) \\ (0 \cdot x ) + (1\cdot y) + (0\cdot z ) + (d_y\cdot 1) \\ (0 \cdot x) + (0 \cdot y ) + (1\cdot z ) + (d_z\cdot 1) \\ (0\cdot x) + (0\cdot y) + (0\cdot z) + (1\cdot 1) \end{bmatrix} = \begin{bmatrix} x + d_x\\ y + d_y\\ z +d_z\\ 1 \\ \end{bmatrix} 100001000010dxdydz1xyz1=(1x)+(0y)+(0z)+(dx1)(0x)+(1y)+(0z)+(dy1)(0x)+(0y)+(1z)+(dz1)(0x)+(0y)+(0z)+(11)=x+dxy+dyz+dz1

二、缩放矩阵

缩放 ( s x , s y , s z ) (s_x,s_y,s_z) (sx,sy,sz)
[ s x 0 0 0 0 s y 0 0 0 0 s z 0 0 0 0 1 ] \begin{bmatrix} s_x & 0 & 0 & 0 \\ 0 & s_y & 0 & 0 \\ 0& 0 & s_z & 0 \\ 0&0&0&1 \end{bmatrix} sx0000sy0000sz00001
例:
[ s x 0 0 0 0 s y 0 0 0 0 s z 0 0 0 0 1 ] ⋅ [ x y z 1 ] = [ ( s x ⋅ x ) + ( 0 ⋅ y ) + ( 0 ⋅ z ) + ( 0 ⋅ 1 ) ( 0 ⋅ x ) + ( s y ⋅ y ) + ( 0 ⋅ z ) + ( 0 ⋅ 1 ) ( 0 ⋅ x ) + ( 0 ⋅ y ) + ( s z ⋅ z ) + ( 0 ⋅ 1 ) ( 0 ⋅ x ) + ( 0 ⋅ y ) + ( 0 ⋅ z ) + ( 1 ⋅ 1 ) ] = [ x ⋅ s x y ⋅ s y z ⋅ s z 1 ] \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} = \begin{bmatrix} (s_x \cdot x )+( 0\cdot y)+ (0\cdot z )+ (0\cdot 1) \\ ( 0 \cdot x )+ (s_y\cdot y )+ (0\cdot z )+ (0\cdot 1 )\\ ( 0 \cdot x)+( 0 \cdot y )+ (s_z\cdot z )+ (0\cdot 1) \\ ( 0 \cdot x)+(0\cdot y)+(0\cdot z)+(1\cdot 1) \end{bmatrix} = \begin{bmatrix} x \cdot s_x\\ y \cdot s_y \\ z \cdot s_z\\ 1 \\ \end{bmatrix} sx0000sy0000sz00001xyz1=

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值