GAMES101-现代计算机图形学入门-闫令琪——Lecture 02 Review of Linear Algebra 学习笔记

Lecture 01 Overview of Computer Graphics

现代计算机图形学的应用

Lecture 02 Review of Linear Algebra

一、Vector Multiplication

(一)、Dot(scalar) Product
1、The Basic Definition of The Dot Product
image-20210111111503612 image-20210111111615539
  • The basic definition of the dot product(最标准的定义式)
image-20210111111953565
  • Find angle between two vectors(求两个向量的夹角)

    ​ e.g. cosine of angle between light source and surface(例如光源与表面夹角余弦)

image-20210111112133879
  • For unit vectors (当 ab为单位向量时,上述的式子可以写成此式)
2、Dot Product in Cartesian Coordinates
  • Component-wise multiplication, then adding up

– in 2D

image-20210111113028977

–in 3D

image-20210111113235185
3、Dot Product in Graphics
(1)Decompose a Vector
image-20210111115014294

ba上的投影可以用下面的式子:

  • image-20210111114204376
  • image-20210111114602589

求出来投影以后,就可以任意将b分解为垂直与平行的两个向量

一个方向即为b,另一个方向为b-b

(2)Determine Forward / Backward
image-20210111120827565

两个向量点乘结果>0,则两个向量同向

两个向量点乘结果<0,则两个向量反向

(3)Measure How Close Two Directions

如上图,若两个向量越近,则点乘结果越接近于1,直到两个向量完全平行,此时点乘结果为1;

​ 若两个向量越远,则点乘结果越接近于0,直到两个向量完全相反,此时点乘结果为-1;

​ 当两个向量垂直时,点乘结果为0

(二)、Cross (vector) Product
1、The Basic Definition of The Cross Product
image-20210111121432517
  • Cross product is orthogonal to two initial vectors (外积正交于两个初始向量)
  • Direction determined by right-hand rule (通过右手定则判断叉乘结果向量的方向)
  • Useful in constructing coordinate systems (在构建空间坐标系的时候很有用)
2、Cross product: Properties
image-20210111133507278
3、Cross Product in Graphics
(1)Determine left / right
image-20210111133724520

判断向量a和向量b的位置关系

用向量a叉乘向量b,即a×b,若得到的结果为正(说明叉乘的结果向量(z)向外,如果用右手螺旋定则去判断,说明大拇指指向外,而根据叉乘顺序是a叉乘b,说明四指由a转向b),则ba的左侧;若得到的结果为负(说明叉乘的结果向量(z)向内,如果用右手螺旋定则去判断,说明大拇指指向内,而根据叉乘顺序是a叉乘b,说明四指由a转向b),则ab的左侧;

同理,还可以

用向量b叉乘向量a,即b×a,若得到的结果为正,则ba的右侧,若得到的结果为负,则ab的右侧

(2)Determine inside / outside
image-20210111135201091

判断点P在三角形ABC内部

默认组成三角形的三个点是逆时针方向排列

首先用向量AB与向量AP叉乘,若结果为正,说明向量AP(点p)在向量AB的左侧

然后用向量BC与向量BP叉乘,若结果为正,说明向量BP(点p)在向量BC的左侧

最后用向量CA与向量CP叉乘,若结果为正,说明向量CP(点p)在向量CA的左侧

若以上三个式子都成立,则说明点p在ABBCCA的左侧,则点p在三角形ABC内

(三)、Orthonormal Bases / Coordinate Frames
Orthonormal Coordinate Frames
  • Important for representing points, positions, locations

  • Often, many sets of coordinate systems

    ​ --Global, local, world, model, parts of model (head,hands, …)

  • Critical issue is transforming between these systems/bases

Any set of 3 vectors (in 3D) that

image-20210111140702372

用向量叉乘可以定义一些相互垂直的轴,这些轴就会形成一个坐标系。

上式中定义了uvw三个单位向量,且相互点乘都为0(即互相垂直),w即可通过u×v得到(右手系)

image-20210111141114700

这样定义的好处是可以把任意一个向量分解到三个轴上(如上式)

二、Matrices

(一)、Matrix-Matrix Multiplication
1、The Basic Operation of Matrix Multiplication

(number of) columns in A must = # rows in B

(M x N) (N x P) = (M x P)

两个矩阵可以做乘法的前提是第一个矩阵的列与第二个矩阵的行相等,得到的新矩阵行数是第一个矩阵的行,列是第二个矩阵的列。

矩阵乘法的计算方法:

image-20210111141752636

若要算第一行第二列位置的值,则用第一个矩阵的第一行与第二个矩阵的第二列求点乘(对应元素相乘后相加),即可得到

Element (i, j) in the product is the dot product of row i from A and column j from B

2、Properties
(1)、Non-commutative

AB and BA are different in general

(2)、Associative and distributive
  • (AB)C=A(BC)
  • A(B+C) = AB + AC
  • (A+B)C = AC + BC
(二)、Matrix-Vector Multiplication
  • Treat vector as a column matrix (m×1) (始终认为矩阵在左边,向量在右边,向量永远是一个列向量(m×1的矩阵))

  • Key for transforming points

  • Official spoiler: 2D reflection about y-axis

    image-20210111142909947

    沿y轴作对称操作

(三)、Transpose of a Matrix
  • Switch rows and columns (ij -> ji)
image-20210111143208016

矩阵转置:行列互换

  • Property
image-20210111143235767
(四)、Identity Matrix and Inverses
  • 单位矩阵
image-20210111143338865
  • 逆矩阵
image-20210111143407839
(五)、Vector multiplication in Matrix form
  • Dot product
image-20210111143654010
  • Cross product
image-20210111143739705
  • 6
    点赞
  • 10
    收藏
    觉得还不错? 一键收藏
  • 2
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值