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:
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....