Game Development Reference
In-Depth Information
2
3
m 11 m 12 m 13
m 21 m 22 m 23
m 31 m 32 m 33
4
5
Subscript notation for
matrix elements
The notation m ij denotes the element in M at row i and column j.
Matrices use 1-based indices, so the first row and column are numbered 1.
For example, m 12 (read “m one two,” not “m twelve”) is the element in the
first row, second column. Notice that this is different from programming
languages such as C++ and Java, which use 0-based array indices. A matrix
does not have a column 0 or row 0. This difference in indexing can cause
some confusion if matrices are stored using an actual array data type. For
this reason, it's common for classes that store small, fixed size matrices of
the type used for geometric purposes to give each element its own named
member variable, such as float m11 , instead of using the language's native
array support with something like float elem[3][3] .
4.1.2
Square Matrices
Matrices with the same number of rows and columns are called square
matrices and are of particular importance. In this topic, we are interested
in 2 × 2, 3 × 3, and 4 × 4 matrices.
The diagonal elements of a square matrix are those elements for which
the row and column indices are the same. For example, the diagonal ele-
ments of the 3 × 3 matrix M are m 11 , m 22 , and m 33 . The other elements
are non-diagonal elements. The diagonal elements form the diagonal of the
matrix:
The diagonal of a 3 × 3
matrix
If all nondiagonal elements in a matrix are zero, then the matrix is a
diagonal matrix. The following 4 × 4 matrix is diagonal:
2
4 3
3
A diagonal 4 × 4 matrix
0
0
0
5
0
1
0
0
.
0
0
−5
0
0
0
0
2
 
Search WWH ::




Custom Search