Game Development Reference
In-Depth Information
While the translation part made perfect sense to me, the 3 x 3 rotation and scaling
part of the matrix was something I never really had a good handle on until the
day I found out that what this part of the matrix actually represents is the size and
direction of the x, y, and z axes.
Take a look at the following image that shows the identity matrix for a 4 x 4 matrix.
All this means is that every element in the matrix is 0 except for those in the top-left
to bottom-right diagonal, which are all 1 :
y
1 0 0 0
0 1 0 0
0 0 1 0
0 0 0 1
Direction of x-axis
Direction of y-axis
Direction of z-axis
Position
Z
X
Notice that the first three numbers on the top row are (1, 0, 0), which just so happens
to be a unit vector along the x axis. Similarly, the second row is (0, 1, 0), which
represents a unit vector along the y axis and the third row (0, 0, 1) is a unit vector
along the z axis.
Once I realized this, it became much more obvious how to create matrices to perform
different kinds of geometric operations.
Want a rotation around the y axis? Just work out vectors for the directions in which
the x axis and z axis would need to lie for the desired rotation, and slot these into the
relevant parts of the matrix. Similarly, a scale operation just means that we provide a
non-unit-sized vector for each axis we want to scale along.
Some of you may be reading this and thinking "that's obvious", but if this helps just
one person to get a better understanding of how to understand matrix mathematics,
my work is done!
Converting between coordinate systems
When we looked at how a 3D model is represented in terms of data, we talked
about the vertices of the model being in model space. In order to use these
vertices for rendering, we therefore have to convert our model space vertices
into screen coordinates.
Search WWH ::




Custom Search