【Games101】Lecture03 变换 整理

视频&图片来源:【B站】GAMES101-现代计算机图形学入门-闫令琪

1. 线性变换


1.1 缩放

1.1.1 均匀缩放


x ′ = s x , y ′ = s y x^{'}=sx,y^{'}=sy x=sxy=sy
矩阵形式表示: [ x ′ y ′ ] = [ s 0 0 s ] [ x y ] \left[\begin{matrix}x^{'}\\y^{'}\end{matrix}\right]=\left[\begin{matrix}s&0\\0&s\\\end{matrix}\right]\left[\begin{matrix}x\\y\end{matrix}\right] [xy]=[s00s][xy],其中, [ s 0 0 s ] \left[\begin{matrix}s&0\\0&s\\\end{matrix}\right] [s00s]称为缩放矩阵


1.1.2 非均匀缩放


矩阵形式表示: [ x ′ y ′ ] = [ s x 0 0 s y ] [ x y ] \left[\begin{matrix}x^{'}\\y^{'}\end{matrix}\right]=\left[\begin{matrix}s_x&0\\0&s_y\\\end{matrix}\right]\left[\begin{matrix}x\\y\end{matrix}\right] [xy]=[sx00sy][xy]



1.2 反射


1.2.1 水平反射


x ′ = − x , y ′ = y x^{'}=-x,y^{'}=y x=xy=y
矩阵形式表示: [ x ′ y ′ ] = [ − 1 0 0 1 ] [ x y ] \left[\begin{matrix}x^{'}\\y^{'}\end{matrix}\right]=\left[\begin{matrix}-1&0\\0&1\\\end{matrix}\right]\left[\begin{matrix}x\\y\end{matrix}\right] [xy]=[1001][xy]

1.3 切变


矩阵形式表示: [ x ′ y ′ ] = [ 1 a 0 1 ] [ x y ] \left[\begin{matrix}x^{'}\\y^{'}\end{matrix}\right]=\left[\begin{matrix}1&a\\0&1\\\end{matrix}\right]\left[\begin{matrix}x\\y\end{matrix}\right] [xy]=[10a1][xy]
要点:

  • y = 0 y=0 y=0时,水平位移为0;在 y = 1 y=1 y=1时,水平位移为 a a a
  • 竖直位移恒为0。

1.4 旋转


旋转矩阵: R θ = [ cos ⁡ θ − sin ⁡ θ sin ⁡ θ cos ⁡ θ ] R_\theta=\left[\begin{matrix}\cos\theta&-\sin\theta\\\sin\theta&\cos\theta\end{matrix}\right] Rθ=[cosθsinθsinθcosθ]

1.5 总结

针对 x x x y y y的变换: x ′ = a x + b y , y ′ = c x + d y x^{'}=ax+by,y^{'}=cx+dy x=ax+byy=cx+dy
写成矩阵形式: [ x ′ y ′ ] = [ a b c d ] [ x y ] \left[\begin{matrix}x^{'}\\y^{'}\end{matrix}\right]=\left[\begin{matrix}a&b\\c&d\\\end{matrix}\right]\left[\begin{matrix}x\\y\end{matrix}\right] [xy]=[acbd][xy]
总的来说: X ′ = M X \Chi^{'}=M\Chi X=MX,其中, M M M为变换矩阵


2. 齐次坐标

2.1 非线性变换

2.1.1 引入:一种非线性变换—平移

平移是一种非线性变换: [ x ′ y ′ ] = [ a b c d ] [ x y ] + [ t x t y ] \left[\begin{matrix}x^{'}\\y^{'}\end{matrix}\right]=\left[\begin{matrix}a&b\\c&d\\\end{matrix}\right]\left[\begin{matrix}x\\y\end{matrix}\right]+\left[\begin{matrix}t_x\\t_y\end{matrix}\right] [xy]=[acbd][xy]+[txty]
我们希望将平移也能以线性变换的形式进行处理。
处理方法(以2D为例):进行维度上的拓展

  • = ( x , y , 1 ) T =(x,y,1)^T =(x,y,1)T
  • 向量 = ( x , y , 0 ) T =(x,y,0)^T =(x,y,0)T

于是,平移变换的矩阵表示可以为: ( x ′ y ′ w ′ ) = ( 1 0 t x 0 1 t y 0 0 1 ) ⋅ ( x y z ) = ( x + t x y + t y 1 ) \left(\begin{matrix}x^{'}\\y^{'}\\w^{'}\end{matrix}\right)=\left(\begin{matrix}1&0&t_x\\0&1&t_y\\0&0&1\end{matrix}\right)\cdot\left(\begin{matrix}x\\y\\z\end{matrix}\right)=\left(\begin{matrix}x+t_x\\y+t_y\\1\end{matrix}\right) xyw=100010txty1xyz=x+txy+ty1

这样做的依据:

  • 向量具有平移不变性,平移方向不变。
  • 扩充的定义: ( x y w ) \left(\begin{matrix}x\\y\\w\end{matrix}\right) xyw是2D点 ( x / w y / w 1 ) \left(\begin{matrix}x/w \\ y/w \\1\end{matrix}\right) x/wy/w1 w ≠ 0 w\not=0 w=0

辅助理解:当 w w w的坐标为0或者1,有效的操作有:

  • 向量+向量=向量
  • 点-点=向量
  • 点+向量=点
  • 点+点=这两个点的中点

2.1.2 仿射变换

一般表示: ( x ′ y ′ ) = ( a b c d ) ( x y ) + ( t x t y ) \left(\begin{matrix}x^{'}\\y^{'}\end{matrix}\right)=\left(\begin{matrix}a&b\\c&d\\\end{matrix}\right)\left(\begin{matrix}x\\y\end{matrix}\right)+\left(\begin{matrix}t_x\\t_y\end{matrix}\right) (xy)=(acbd)(xy)+(txty)


使用齐次坐标表示: ( x ′ y ′ 1 ) = ( a b t x c d t y 0 0 1 ) ⋅ ( x y 1 ) \left(\begin{matrix}x^{'}\\y^{'}\\1\end{matrix}\right)=\left(\begin{matrix}a&b&t_x\\c&d&t_y\\0&0&1\end{matrix}\right)\cdot\left(\begin{matrix}x\\y\\1\end{matrix}\right) xy1=ac0bd0txty1xy1

  • 缩放矩阵: S ( s x , s y ) = ( s x 0 0 0 s y 0 0 0 1 ) S(s_x,s_y)=\left(\begin{matrix}s_x&0&0\\0&s_y&0\\0&0&1\end{matrix}\right) S(sx,sy)=sx000sy0001
  • 旋转矩阵: R ( α ) = ( cos ⁡ α − sin ⁡ α 0 sin ⁡ α cos ⁡ α 0 0 0 1 ) R(\alpha)=\left(\begin{matrix}\cos\alpha&-\sin\alpha&0\\\sin\alpha&\cos\alpha&0\\0&0&1\end{matrix}\right) R(α)=cosαsinα0sinαcosα0001
  • 平移矩阵: T ( t x , t y ) = ( 1 0 t x 0 1 t y 0 0 1 ) T(t_x,t_y)=\left(\begin{matrix}1&0&t_x\\0&1&t_y\\0&0&1\end{matrix}\right) T(tx,ty)=100010txty1

2.1.3 变换的组合

  • 复杂变换可以通过一系列简单变换得到
  • 变换的顺序不同结果不同从右到左逐个应用(原理:矩阵乘法)
    预乘 n 个矩阵以获得表示组合变换的单个矩阵

e.g. 先逆时针旋转45°,再水平平移一个单位
T ( 1 , 0 ) ⋅ R 45 [ x y 1 ] = ( 1 0 1 0 1 0 0 0 1 ) ( cos ⁡ 45 ° − sin ⁡ 45 ° 0 sin ⁡ 45 ° cos ⁡ 45 ° 0 0 0 1 ) [ x y 1 ] T_{(1,0)}\cdot R_{45}\left[\begin{matrix}x\\y\\1\end{matrix}\right]=\left(\begin{matrix}1&0&1\\0&1&0\\0&0&1\end{matrix}\right)\left(\begin{matrix}\cos45\degree&-\sin45\degree&0\\\sin45\degree&\cos45\degree&0\\0&0&1\end{matrix}\right)\left[\begin{matrix}x\\y\\1\end{matrix}\right] T(1,0)R45xy1=100010101cos45°sin45°0sin45°cos45°0001xy1


2.2 逆变换

3. 三维变换

  • 3D点 = ( x , y , z , 1 ) T =(x,y,z,1)^T =(x,y,z,1)T
  • 3D向量 = ( x , y , z , 0 ) T =(x,y,z,0)^T =(x,y,z,0)T
  • 扩充的定义: ( x y z w ) \left(\begin{matrix}x\\y\\z\\w\end{matrix}\right) xyzw是3D点 ( x / w y / w z / w ) \left(\begin{matrix}x/w \\ y/w \\z/w\end{matrix}\right) x/wy/wz/w w ≠ 0 w\not=0 w=0
  • 齐次坐标变换矩阵: ( x ′ y ′ z ′ 1 ) = ( a b c t x d e f t y g h i t z 0 0 0 1 ) ⋅ ( x y z 1 ) \left(\begin{matrix}x^{'}\\y^{'}\\z^{'}\\1\end{matrix}\right)=\left(\begin{matrix}a&b&c&t_x\\d&e&f&t_y\\g&h&i&t_z\\0&0&0&1\end{matrix}\right)\cdot\left(\begin{matrix}x\\y\\z\\1\end{matrix}\right) xyz1=adg0beh0cfi0txtytz1xyz1
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
毕业设计,基于SpringBoot+Vue+MySQL开发的体育馆管理系统,源码+数据库+毕业论文+视频演示 现代经济快节奏发展以及不断完善升级的信息化技术,让传统数据信息的管理升级为软件存储,归纳,集中处理数据信息的管理方式。本体育馆管理系统就是在这样的大环境下诞生,其可以帮助管理者在短时间内处理完毕庞大的数据信息,使用这种软件工具可以帮助管理人员提高事务处理效率,达到事半功倍的效果。此体育馆管理系统利用当下成熟完善的SpringBoot框架,使用跨平台的可开发大型商业网站的Java语言,以及最受欢迎的RDBMS应用软件之一的Mysql数据库进行程序开发。实现了用户在线选择试题并完成答题,在线查看考核分数。管理员管理收货地址管理、购物车管理、场地管理、场地订单管理、字典管理、赛事管理、赛事收藏管理、赛事评价管理、赛事订单管理、商品管理、商品收藏管理、商品评价管理、商品订单管理、用户管理、管理员管理等功能。体育馆管理系统的开发根据操作人员需要设计的界面简洁美观,在功能模块布局上跟同类型网站保持一致,程序在实现基本要求功能时,也为数据信息面临的安全问题提供了一些实用的解决方案。可以说该程序在帮助管理者高效率地处理工作事务的同时,也实现了数据信息的整体化,规范化与自动化。 关键词:体育馆管理系统;SpringBoot框架;Mysql;自动化
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值