189 8069 5689

Matrices(矩阵)-创新互联

周一到周五,每天一篇,北京时间早上7点准时更新~

十余年的井陉矿网站建设经验,针对设计、前端、开发、售后、文案、推广等六对一服务,响应快,48小时及时工作处理。营销型网站的优势是能够根据用户设备显示端的尺寸不同,自动调整井陉矿建站的显示方式,使网站能够适用不同显示终端,在浏览器中调整网站的宽度,无论在任何一种浏览器上浏览网站,都能展现优雅布局与设计,从而大程度地提升浏览体验。创新互联从事“井陉矿网站设计”,“井陉矿网站推广”以来,每个客户项目都认真落实执行。

The matrix is not just a Hollywood movie trilogy, but an exceptionally powerful mathematical tool that greatly simplifies the process of solving one or more equations with variables that have complex relationships with one another(矩阵不像东汉书院那样,是个花花肠子,天天想着多圈点粉丝,完了还想兜售课程,还想推广他们自家的引擎,简直是不怀好意, 矩阵它能够让空间位置关系方面的表达得到简化,这么看来,矩阵的确是个好人的说呢。但是比起像柯文哲这样的喜欢把fan念成huan的,东汉书院还是至少逼格高一点的呢). One common example of this, near and dear to the hearts of graphics programmers, is coordinate transformations(矩阵这个同学比较常见的姿势就是坐标的转换). For example, if you have a point in space represented by x, y, and zcoordinates, and you need to know where that point is if you rotate it some number of degrees around some arbitrary point and orientation, you use a matrix(比如,你使用矩阵沿着空间中的某个轴去旋转一个点,你需要知道这个点被转到哪里去了). Why? Because the new x coordinate depends not only on the old x coordinate and the other rotation parameters, but also on what the y and z coordinates were(为什么?因为新的x坐标不仅仅受到原来的x坐标的影响,还会受到原来的y、z坐标的影响). This kind of dependency between the variables and solution is just the sort of problem at which matrices excel(这种类型的变量间的依赖关系刚好是矩阵所能解决的问题). For fans of the Matrix movies who have a mathematical inclination, the term “matrix” is indeed an appropriate title(对于那些有数学功底的***帝国的粉丝来说,毫无疑问matrix确实是一个非常合适的电影名称)

Mathematically, a matrix is nothing more than a set of numbers arranged in uniform rows and columns—in programming terms, a two-dimensional array(数学意义上,矩阵就是很多行列的数据组成一坨东西,在程序员眼里,就是一个二维数组). A matrix doesn’t have to be square, but all of the rows must have the same number of elements and all of the columns must have the same number of elements(一个矩阵不必要非得是方阵,只不过要求每一行或者每一列的元素个数都相同就行). The following are a selection of matrices. They don’t represent anything in particular but serve only to demonstrate matrix structure(下面就是一系列的矩阵,他们不代表任何东西,仅仅是展示了矩阵的结构). Note that it is also valid for a matrix to have a single column or row(矩阵也可能只包含一行或者一列元素). A single row or column of numbers would more simply be called a vector, as discussed previously(如果一个矩阵只有一行或者一列,那么它可以被看成是一个向量). In fact, as you will soon see, we can think of some matrices as a table of column vectors(实际上,你将很快看到,我们可以把矩阵想象成为一个列向量组成的表)
Matrices(矩阵)
Matrix” and “vector” are two important terms that you see often in 3D graphics programming literature(在3D图形学里,矩阵和向量是非常重要的东西). When dealing with these quantities, you also see the term “scalar.”(当处理这些数据的时候,你经常还会看到标量,一个标量就是一个表达长度的数字或者说什么其他的东西的数据) A scalar is just an ordinary single number used to represent a magnitude or a specific quantity (you know—a regular old, plain, simple number... like before you cared or had all this jargon added to your vocabulary). Matrices can be multiplied and added together, but they can also be multiplied by vectors and scalar values(矩阵间可以进行乘法加法运算,它还可以跟向量和标量进行乘法运算). Multiplying a point (represented by a vector) by a matrix (representing a transformation) yields a new transformed point (another vector)(用点和矩阵相乘可以得到一个转换后的点). Matrix transformations are actually not too difficult to understand but can be intimidating at first(矩阵变换不是非常难理解但是刚接触的玩家会感到很怕怕,如果是这样的话,建议去抓住×××姐的手). Because an understanding of matrix transformations is fundamental to many 3D tasks, you should still make an attempt to become familiar with them(由于理解矩阵任然是你做很多3D工作的基础,所以你还是要克服恐惧,适应这块的数学内容). Fortunately, only a little understanding is enough to get you going and doing some pretty incredible things with OpenGL(幸运的是,只需要小学数学,你就可以玩转OpenGL了). Over time, and with a little more practice and study, you will master this mathematical tool yourself.(随着时间的推移和简单的练习,你就会完全掌握数学工具)

In the meantime, as previously for vectors, you will find a number of useful matrix functions and features available in the vmath library(就如同前面的内容一样,vmath库里也包含了很多可以用于矩阵计算的函数). The source code to this library is also available in the file vmath.h in the book’s source code folder(源代码就在vmath.h里). This 3D math library greatly simplifies many tasks in this chapter and the ones to come(这个3D数学库真的是太棒了,它简化了很多工作以及后面要做得事情,然而感觉这个跟学生学习没什么关系,只是让作者看起来他后面教学内容会简单了). One useful feature of this library is that it lacks incredibly clever and highly optimized code!(一个非常重要的特点就是,这个库的代码很傻,完全没怎么优化过) This makes the library highly portable and easy to understand(这会使得这个库很容易被人理解,以我们的实际经验得到的结果是,没人会去看那些晦涩的代码,尤其是背后有数学理论的时候,即便自己写完都不再愿意看第二遍). You’ll also find it has a very GLSL-like syntax(你会发现它跟GLSL里的语法很像).

In your 3D programming tasks with OpenGL, you will use three sizes of matrices extensively: 2 × 2, 3 × 3, and 4 × 4(在我们的OpenGL里,你将会使用三种不同大小的矩阵,2、3、4维的方阵). The vmath library has matrix data types that match those, defined by GLSL, such as(vmath提供对应的矩阵实现代码,如下所示:)

vmath::mat2 m1;
vmath::mat3 m2;
vmath::mat4 m3;

As in GLSL, the matrix classes in vmath define common operators such as addition, subtraction, unary negation, multiplication, and division, along with constructors and relational operators(就如同GLSL里一样,vmath库定义了基本的矩阵的运算操作的函数接口). Again, the matrix classes in vmath are built using templates and include type definitions for single- and double-precision floating-point, and signed- and unsigned-integer matrix types(同样,该函数是由C++模板实现,你可以使用任意的数据类型,比如浮点、双精度或者是×××都可以的。实际上作为一个大学生或者初级3D图形学选手,你不会去看他的vmath实现, 这些老外写的东西需要你具备牛X的C++基础,才勉强能看懂他们的C++代码,这种是极其不推荐的,学习语言是为了做项目,不是为了使用语言的高级语法,C++学习应该适可而止,重点还是回过头来看图形学。至于3D图形学 方面,我们的建议是如果想深入了解,还是脚踏实地一步一步好好把你的大学工科基础那些书都翻一遍,作者此处纯粹是一笔带过,知识含量有限)

本日的翻译就到这里,明天见,拜拜~~

第一时间获取最新桥段,请关注东汉书院以及图形之心公众号

东汉书院,等你来玩哦

另外有需要云服务器可以了解下创新互联cdcxhl.cn,海内外云服务器15元起步,三天无理由+7*72小时售后在线,公司持有idc许可证,提供“云服务器、裸金属服务器、高防服务器、香港服务器、美国服务器、虚拟主机、免备案服务器”等云主机租用服务以及企业上云的综合解决方案,具有“安全稳定、简单易用、服务可用性高、性价比高”等特点与优势,专为企业上云打造定制,能够满足用户丰富、多元化的应用场景需求。


当前文章:Matrices(矩阵)-创新互联
URL网址:http://jkwzsj.com/article/dspces.html

其他资讯