《3D Math Primer for Graphics and Game Development》读书笔记2

本文深入探讨了3D图形和游戏开发中的矩阵与线性变换概念,包括旋转、缩放、投影、镜像和切变等变换方式,并介绍了矩阵的行列式、逆矩阵以及正交矩阵的相关知识。

《3D Math Primer for Graphics and Game Development》读书笔记2

上一篇得到了"矩阵等价于变换后的基向量"这一结论。

本篇只涉及两章,但容量已足够喝一壶了。

第8章 矩阵和线性变换

变换物体和变换坐标系是等价的,将物体变换一个量等价于将坐标系变换一个相反的量。

旋转rotation

2D中的旋转只有一个参数:角度θ,逆时针经常被认为是正方向。

在3D场景中,绕轴旋转而不是点。绕轴旋转θ°时,必须知道哪个方向被认为是正方向。在左手坐标系中用左手法则,在右手坐标系中用右手法则判定。

为单位向量,方向任意,旋转角度为θ,那么相应的旋转矩阵为:

缩放scaling

为平行于缩放方向的单位向量,k为缩放因子,缩放沿穿过原点且平行于的直线(2D)或平面(3D)进行。

2D的缩放公式

3D的缩放公式

投影projection

2D中,

3D中,

镜像reflection

2D中,

3D中,

切变shearing

切变时角度会变化,但面积和体积不变。

第9章 矩阵的更多知识

行列式determinant

上图展示了行列式的计算方法。可以将任意一行作为主行,然后写出行列式;也可以按列来写,结果都是一样的。

2×2矩阵的行列式等于其围成的平行四边形的有符号面积。

3×3矩阵的行列式等于以变换后的基向量为三边的平行六面体的有符号体积。

如果行列式为零,那么该矩阵包含投影;如果行列式为负,那么该矩阵包含镜像。

矩阵的逆

假设矩阵M有r行c列。记法M{ij}表示从M中除去第i行第j列后剩下的矩阵。称为M余子式。余子式是一个矩阵。

余子式的有符号行列式称为代数余子式

用Cij表示M的第i行第j列元素的代数余子式。代数余子式是一个标量。

可以用代数余子式求行列式。

例如4×4矩阵

矩阵M的逆记作M-1,也是一个矩阵,且满足

M标准伴随矩阵记作adj M,定义为M的代数余子式矩阵的转置矩阵。例如:

M的代数余子式矩阵:

M的标准伴随矩阵:

M的逆矩阵:

标准伴随矩阵提供无分支计算逆矩阵的方法。还有一种求逆矩阵的方法是高斯消元法。

正交矩阵

旋转和镜像矩阵是正交的。

正交矩阵的每一行代表的基向量都是单位向量,且行互相垂直。

矩阵正交化

施密特正交化:

改进的施密特正交化:

4×4齐次矩阵

4×4矩阵可以同时表示线性变换(旋转、缩放。。。)和平移。这是使用4×4矩阵的原因之一。

仿射变换

仿射变换的基本思路是,先平移到原点,然后执行线性变换,最后反向平移回去。

 

转载于:https://www.cnblogs.com/bitzhuwei/p/reading-notes2-3D-Math-Primer-for-Graphics-and-Game-Development.html

If you want to learn about 3D math in order to program games or graphics, then this book is for you. There are many books out there that promise to teach you how to make a game or put cool pictures up on the screen, so why should you read this particular book? This book offers several unique advantages over other books about games or graphics programming:  A unique topic. This book fills a gap that has been left by other books on graphics, linear algebra, simulation, and programming. It is an introductory book, meaning we have focused our efforts on providing thorough coverage on fundamental 3D concepts — topics that are normally glossed over in a few quick pages or relegated to an appendix in other publications (because, after all, you already know all this stuff). Our book is definitely the book you should read first, before buying that “Write a 3DVideoGame in 21Days” book. This book is not only an introductory book, it is also a reference book — a “toolbox” of equations and techniques that you can browse through on a first reading and then revisit when the need for a specific tool arises. 1 A unique approach. We take a three-pronged approach to the subject matter: math, geome- try, and code. The math part is the equations and numbers. This is where most books stop. Of course, the math is important, but to make it powerful, you have to have good intuition about how the math connects with the geometry.We will show you not just one but multiple ways to relate the numbers with the geometry on a variety of subjects, such as orientation in 3D, matrix multiplication, and quaternions. After the intuition comes the implementation; the code part is the practical part.We show real usable code that makes programming 3D math as easy as possible.  Unique authors. Our combined experience brings together academic authority with in-the-trenches practical advice. Fletcher Dunn has six years of professional game program- ming experience and several titles under his belt on a var
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值