Game Development Reference
In-Depth Information
Figure 8.21
A visual representation of a matrix.
Before covering matrix operations, it's time to make the basic class.
public class Matrix
{
double _m11, _m12, _m13;
double _m21, _m22, _m23;
double _m31, _m32, _m33;
double _m41, _m42, _m43;
}
Here is the Matrix class based on a 4x3 layout. Its member variables are laid out
in a similar way to Figure 8.18 but there is no fourth column (we know the fourth
column will always be [0, 0, 0, 1] so the values don't need to be stored). The
Vector , Color , and Point components were all structures, but the Matrix is
a larger component so it has been declared as a class.
In the following sections, we'll flesh out the Matrix class and add some opera-
tions to it.
The Identity Matrix
The identity matrix is the matrix that when multiplied by any other matrix will
not modify it in any way. The number 1 is an example of an identity in real
numbers; any number multiplied by 1 results in the original number unchanged.
 
Search WWH ::




Custom Search