GAMES101-现代计算机图形学入门-闫令琪——Lecture 03 Transformation 学习笔记

Lecture 03 Transformation

一、2D transformations

(一)、Representing transformations using matrices
1、Scale (Non-Uniform) Matrix
image-20210112160050119 image-20210112160104886
2、Reflection Matrix
image-20210112160140631

image-20210112160204185 image-20210112160220271

3、Shear Matrix
image-20210112160308532

image-20210112160327868 image-20210112160346482

4、Rotation Matrix
image-20210112160522057 image-20210112160533441

旋转矩阵的推导过程:

image-20210112160641432

同理,B和D位置的推导选取点(0,1)即可

5、Linear Transforms = Matrices

以上的几种变换均属于线性变换,都可以用下列的公式表示

image-20210112163535196

但是一旦涉及到移动,就无法通过上述的公式来实现了。

image-20210112163713343 image-20210112163730672

So, translation is NOT linear transform(因此我们可以看到,位移不属于线性变换)

  • Translation cannot be represented in matrix form
  • But we don’t want translation to be a special case
  • Is there a unified way to represent all transformations? (and what’s the cost?)

如何将位移与前面提到的旋转、缩放等线性变换作一个统一?

我们引入了齐次坐标(下文)

(二)、Homogeneous coordinates
1、General Introduction

Add a third coordinate (w-coordinate)

我们通过在二维中引入第三个坐标w,将维度升高到三维,但是依然表示的是二维坐标。

  • 2D point = (x, y, 1) T
  • 2D vector = (x, y, 0)T

引入齐次坐标后,我们再来看刚刚的位移,我们可以写成下面这个形式,其中tx和ty分别表示沿x轴和y轴的位移值

image-20210112164902428

那么在上面我们为什么要区分2D point和 2D vector?原因如下:

Valid operation if w-coordinate of result is 1 or 0

  • vector + vector = vector
  • point – point = vector
  • point + vector = point
  • point + point = midpoint

这样可以满足一般的数学运算规律,例如两个向量相加结果依然为向量,即w=0,两个点相减结果为向量,此时w:1-1=0,点与向量相加(一个点沿着一个方向移动一段距离)结果仍为一个点,即w=1

  • In homogeneous coordinates
image-20210112170315538

要保持w的值始终为1,只需要将x和y同时除以w即可

2、2D Transformations

Affine map = linear map + translation

image-20210112170552664

Using homogenous coordinates:

image-20210112170608943
(1)Scale
image-20210112170639472
(2)Rotation
image-20210112170656426
(3)Translation
image-20210112170714536
3、Inverse Transform

M-1 is the inverse of transform in both a matrix and geometric sense

image-20210112170913142

逆变换在数学运算中即为逆矩阵

(三)Composing Transforms
image-20210112171041557

将第一幅图变换到第二幅图有哪几种组合变换的方式呢?

image-20210112171124956

第一种方式是先位移后旋转,显然结果并不是我们想要的,还有一种方式就是先旋转后位移。

通过这个案例我们也可以看出

  • Matrix multiplication is not commutative(矩阵乘法是不能交换的)
image-20210112171246414
  • Note that matrices are applied right to left(矩阵乘法是从右向左相乘的)
image-20210112171332799

在一个组合变换中,虽然矩阵乘法不满足交换律,但是依然满足结合律

Sequence of affine transforms A1, A2, A3, …

image-20210112171547947

这也就意味着,无论经历了多少次变换,总能把所有变换计算出来写成一个总的变换矩阵

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值