Working with the transformation matrix
In game development, the transformation matrix is also a common term. Specifically, we use the transformation matrix to encode transformations, including translation, rotation, and scaling transforms.
Unity provides us with the Matrix4x4 struct in C# to represent a standard 4x4 transformation matrix.
As shown in Figure 7.24, a transformation matrix is a grid of numbers. Although it is a common term, we rarely use this matrix directly in scripts. This is because the calculation of the matrix is relatively cumbersome, and Unity, as an easy-to-use game engine, has encapsulated the complex calculations in the Transform
class for us, and we only need to call some functions. Therefore, in this section, we only give a brief introduction to the transformation matrix.
Before we start, you should know that transformations include translation, rotation, scaling, and these operations can...