Game Development Reference
In-Depth Information
The matrix shown in Equation (2.13) is a two-dimensional matrix with three rows and three
columns. Matrices can be of any dimension. In this topic, we will use 1-, 2-, and 3-dimensional
matrices. Matrices are commonly used in the development of mathematical and physics models.
In this topic, we will make use of matrices when we model an airplane in flight and when we
model collisions between objects.
Matrix Multiplication
Just as with vectors, you can add, subtract, and multiply matrices together. Adding or subtracting
matrices involves simply adding or subtracting the individual elements, but the matrices must
have the same dimensions. Multiplying matrices is a little more complicated. In this topic, we
will only concern ourselves with multiplying two-dimensional matrices. In this case, the elements
of the final array are found by multiplying each row of the first array with each column of the
second array. For example, let's say we want to multiply two two-dimensional arrays, each
having three rows and three columns as shown in Equation (2.14).
⎤ ⎡
aaabbb
Caaabbb
aaabbb
11
12
13
⎥ ⎢
11
12
13
[]
⎥ ⎢
=
(2.14)
⎥ ⎢
21
22
23
21
22
23
⎥ ⎢
⎥ ⎢
⎦ ⎣
31
32
33
31
32
33
The first element of the [ C ] array is found by multiplying the elements in the first row of the
[ A ] array with the elements in the first column of the [ B ] array.
cababab
=++
(2.15)
11
11 11
12
21
13
31
The other elements of the [ C ] array are found in a similar manner. When multiplying two-
dimensional arrays, the two arrays don't have to have the same dimensions, but the number of
columns of the first matrix must equal the number of rows of the second matrix.
Matrix multiplication is a common feature to many mathematics and physics models. In
this topic, we'll use matrix multiplication when we create an airplane flight simulator in Chapter 10.
Rotation Matrices
Previously in this chapter we discussed how a coordinate system is required to specify the loca-
tion of an object in two- or three-dimensional space. The orientation of the coordinate axes is
arbitrary; one orientation is equally as valid as any other. Most of the time in this topic when we
are using the Cartesian frame of reference, the x- and y-coordinate axes will be oriented such
that they are parallel to the earth's surface, and the z-axis will be in the vertical direction, perpen-
dicular to the earth. This orientation works well when analyzing the motion of projectiles, cars,
boats, basketballs, and so on.
Search WWH ::




Custom Search