Matrix multiplication can also be used to scale objects in your game. Just like translation, if you scale each individual vertex, you end up scaling the whole object. Let's set up another matrix equation for scaling. Again, we'll start with 2D and then extend to 3D.

2D Scaling

where Sx = scale factor in the x direction and Sy = scale factor in the y direction.

As soon as you plug in the scale factors (Sx and Sy), the process is the same as translation: Plug in each vertex one at a time, and multiply the matrices to find its new location. If you want to perform a uniform scale to keep the proportions the same, just make sure that Sx = ...

Get Beginning Math and Physics for Game Programmers now with the O’Reilly learning platform.

O’Reilly members experience live online training, plus books, videos, and digital content from nearly 200 publishers.