官术网_书友最值得收藏!

What is a matrix?

A matrix is a two-dimensional array of numbers. A square matrix is one whose width and height are the same. In this chapter, you will implement a 4 x 4 matrix; that is, a matrix with four rows and four columns. The elements of this matrix will be stored as a linear array.

A 4 x 4 matrix can be thought of as four vectors that have four components each, or an array of vec4s. If the vectors represent the columns of the matrix, the matrix is column-major. If the vectors represent the rows of the matrix, it is row-major.

Assuming a 4 x 4 matrix contains the letters A, B, C, D … P of the alphabet, it can be constructed as either a row- or column-major matrix. This is demonstrated in the following Figure 3.1:

Figure 3.1: Comparing row- and column-major matrices

Figure 3.1: Comparing row- and column-major matrices

Most math books and OpenGL use column-major matrices. In this chapter, you will be implementing column-major matrices as well. Understanding what is in a matrix is important. The diagonal of the matrix contains scaling information, and the final column contains translation:

Figure 3.2: What is stored in a matrix?

Figure 3.2: What is stored in a matrix?

The upper 3 x 3 submatrix contains three vectors; each of these is a basis vector for the matrix's rotation. The basis vectors are the up, right, and forward directions stored in the matrix. You might have noticed that the rotation and scale components occupy the same space in the matrix.

主站蜘蛛池模板: 汉中市| 渭源县| 江门市| 集安市| 临洮县| 昂仁县| 辛集市| 肇东市| 龙游县| 芦溪县| 嘉禾县| 泰宁县| 云和县| 绥棱县| 兴和县| 兴义市| 大姚县| 米脂县| 泌阳县| 大洼县| 嘉义县| 易门县| 龙岩市| 新平| 宜兰市| 宜良县| 孙吴县| 澄迈县| 吉林省| 平凉市| 和硕县| 汾阳市| 广平县| 鱼台县| 腾冲县| 曲周县| 银川市| 沅陵县| 铜川市| 新民市| 贵港市|