If you recall your elementary school math experience, you hopefully remember that anything plus zero doesn’t change the original number, nor does anything multiplied by one. Well, the same thing is true for matrices. For addition and subtraction of matrices you use what is
known as the zero matrix. Adding or subtracting a zero matrix to or from any other matrix will result in a matrix identical to the original, just like adding zero to a real number gives you your original number. A zero matrix is exactly what it sounds like, a matrix full of zeros. Every element in the zero matrix contains a value of zero. A 3×3 zero matrix is shown in Figure 1.3.
The identity matrix takes the place of the one in multiplication. Any matrix multiplied by the identity matrix will be exactly the same as the original matrix. The identity matrix is a square matrix that contains all zeros, with the exception of the diagonal. The diagonal elements starting at the top-left of the matrix and traveling to the bottom right contain ones instead of zeros. Why ones and zeros? The reason for this goes back to the definition of a matrix as a system of equations. The elements in a matrix represent the coefficients of that system. If you remember back to algebra again, when all of the coefficients in one of the equations is zero but one, it means you have solved for that variable. An identity matrix is just that. For each row or column there is a single “one,” meaning the system of equations has been solved. Setting a matrix to the identity matrix essentially “resets” the matrix.
For example, if the matrix is being used to position geometry, such as the case with OpenGL’s Modelview matrix, changing the matrix to the identity matrix (via glLoadIdentity() in OpenGL) will cause the next parts of the geometry received to be drawn relative to the origin again, rather than relative to the position specified by the previous matrix. Figure 1.3 shows the 3×3 identity matrix.
"o |
0 |
o" |
~1 |
0 |
o" |
||
A = |
0 |
0 |
0 |
1 = |
0 |
1 |
0 |
0 |
0 |
0 |
0 |
0 |
1 |
Figure 1.3 The zero matrix and the identity matrices, both 3×3.They can be used as placeholders when you do not want to modify your original matrix. The identity matrix can also be used to reset transformations; anything transformed by the identity matrix will not be transformed at all. |