Translating points in 3D
We first encountered OpenGL’s translations and rotations back in Chapter 4, Graphics and Game Engine Components, and then began building a Transform
class for our Python project in Chapter 6, Updating and Drawing the Graphics Environment. In this chapter, we will continue working on this class to provide all the functionality of affine transformations, beginning with that of translation.
Whichever affine transformation you are applying, the rule is that the operation is applied to every point to which you want to apply the transformation. In the case of the vertices of a cube, you may have six vertices, as shown in Figure 12.2. This cube is centered around the origin:
Figure 12.2: A cube with each vertex coordinate displayed
To translate the cube—that is, to move it to another location—we must perform the same operation on each of the vertices such that they maintain the integrity of the cube. That means that...