38 CHAPTER 2: All That Math Jazz^
With scaling, as with the other two transformations, the order is very important when
applied to your geometry. Say, for example, you wanted to rotate and move your object.
The results will clearly be different depending on whether you do the translation first or
last. The more common sequence is to rotate the object first and then translate, as
shown in Figure 2-3 (left). But if you invert the order, you’ll get something like Figure 2-3
(right). In both these instances, the rotation is happening around the point of origin. If
you wanted to rotate the object around its own origin, the first example is for you. If you
meant for it to be rotated with everything else, the second works. (A typical situation
might have you translate the object to the world origin, rotate it, and translate it back.)
Figure 2-3. Rotation around the point of origin followed by a translation (left) vs. translation followed by rotation
(right)
So, what does this have to do with the 3D stuff? Simple! Most if not all of the principles
can be applied to 3D transformations and are more clearly illustrated with one less
dimension.
3D Transformations
When moving everything you’ve learned to 3D space (also referred to as 3-space), you’ll
see that, as in 2D, 3D transformations can be expressed as a matrix and as such can be
concatenated with other matrices. The extra dimension of z is now the depth of the
scene going in and out of the screen. OpenGL ES has +z coming out and ---z going in.
Other systems might have that reversed or even have Z being the vertical, with y now
assuming depth. I’ll stay with the OpenGL convention, as shown in Figure 2-4.
4