周一到周五,每天一篇,北京时间早上7点准时更新~
As noted, coordinates may be moved from space to space by multiplying their vector representations by transformation matrices(如同提到过的那样,坐标可以通过乘以变换矩阵从一个空间转换到另一个空间). Transformations are used to manipulate your model and the particular objects within it(变换主要是用来去计算特定空间中你的模型以及某些特定的物体). These transformations move objects into place, rotate them, and scale them(这些变换把物体移动到某个位置,旋转他们,缩放他们). Figure 4.8 illustrates three of the most common modeling transformations that you will apply to your objects(图4.8显示了三个最常见的你会应用到你物体上的模型变换). Figure 4.8(a) shows translation, in which an object is moved along a given axis(图4.8a显示了平移,这里是把一个物体沿着一个给定的坐标轴平移). Figure 4.8(b) shows a rotation, in which an object is rotated about one of the axes(图4.8b显示了旋转,物体绕着某个轴旋转). Finally, Figure 4.8(c) shows the effects of scaling, where the dimensions of the object are increased or decreased by a specified amount(最后图4.8c中显示了缩放物体). Scaling can occur non-uniformly (the various dimensions can be scaled by different amounts), so you can use scaling to stretch and shrink objects(各方向上的缩放可以不一样,这样一来你就可以来挤压物体)
Each of these standard transforms can be represented as a matrix by which you can multiply your vertex coordinates to calculate their positions after the transformation(每一个标准变换可以表示成为使用一个矩阵乘以你的坐标). The following subsections discuss the construction of those matrices, both mathematically and using the functions provided in the vmath library(接下来的章节从数学意义上以及vmath库的角度讨论矩阵的构造)
The Identity Matrix(单位矩阵)
There are a number of important types of transformation matrices you need to be familiar with before we start trying to use them(在你开始使用矩阵之前,你需要先了解一些非常重要的矩阵类型). The first is the identity matrix(第一个就是单位矩阵). As shown below, the identity matrix contains all zeros except a series of ones that traverse the matrix diagonally. The 4 × 4 identity matrix looks like this:(如同下面展示的这样,单位矩阵是一个对角阵,除了对角线上的元素以外,其他地方都是0,,4x4的单位矩阵长相如此:)
Multiplying a vertex by the identity matrix is equivalent to multiplying it by 1; it does nothing to it(与单位矩阵相乘,向量不变)
Objects drawn using the identity matrix are untransformed; they are at the origin (last column), and the x, y, and z axes are defined to be the same as those in eye coordinates(使用单位矩阵去对物体进行变换,物体不会有什么变化). Obviously, identity matrices for 2 × 2 matrices, 3 × 3 matrices, and matrices of other dimensions exist and simply have ones in their diagonal(很显然,2、3和其他维度的单位矩阵也是存在的,所有的单位矩阵都是方阵&#