Game Development Reference
In-Depth Information
y
(Vector A) cross (Vector B)
z
Vector B
Vector A
x
Figure 3-15. Cross product
Listing 3-8. Cross Product Function
void crossProduct(Vector3 b)
{
Set((y*b.z) - (z*b.y),
(z*b.x) - (x*b.z),
(x*b.y) - (y*b.x));
}
Matrices and Matrix Operations
In this section, I cover matrices and matrix operations. I first discuss the definition of a matrix. I then
cover various key topics related to matrix math and the key properties of matrices as they relate to
3D computer graphics needed to develop a 3D game on the Android mobile platform. This section is
not meant to cover every aspect of matrices but is a quick-start guide to matrices and matrix math
operations that are essential to 3D game programming.
What Is a Matrix?
Matrices are key in 3D graphics. They are used to determine properties such as the final position of
3D objects, the rotation of 3D objects, and the scaling of 3D objects. A matrix is defined in Figure 3-16 .
A matrix consists of columns and rows of numbers. The general notation we will use is that of Amn.
The subscript m refers to the row number, and the n refers to the column number. For example, the
notation A23 refers to the number at row 2, column 3.
Figure 3-16. Definition of a matrix
 
Search WWH ::




Custom Search