Table of contents
1. What is the essence of matrix?
2. Several basic transformation applications of matrices
Foreword:
This part is the basic knowledge about matrix transformation in the GAMERS101 course (Lecture 3 Transformation), and the pre-requisite knowledge is the basic operation of matrix
1. What is the essence of matrix?
Q: What is the essence of matrix?
A: Transform.
2. Several basic transformation applications of matrices
Note: All the following operations are temporarily based on two-dimensional transformation, and do not involve three-dimensional transformation operations
2.1 Scale scaling
where s is the scaling factor
2.2 Reflection mirroring
Mirror along the y-axis
2.3 Shear
Make a bevel along the x-axis, a controls the degree of bevel
2.4 Rotate rotation
θ is the rotation angle, the default is counterclockwise, and it is based on the origin
The above four transformations are linear transformations (Linear Transform), and their forms can be written uniformly as
2.5 Translation translation
Translation is not a linear transformation, and its matrix form is different from the above four
Therefore, the concept of homogeneous coordinates is introduced
3. Homogenous Coordinates
That is, on the basis of the original matrix, one more row and one column is added, so that the translation transformation can also be written in the form
So the translation transformation can be written as:
Note: The meaning of w can be understood as, when it is 1, it is a point point written in homogeneous coordinates; when it is 0, it is a vector vector
vector + vector = vector
point - point = vector
point + vector = point
point + point = midpoint*2
Therefore, the above transformation matrix M can be written as follows:
3.1 Scale
3.2 Rotation
3.3 Translation
Since the matrix operation does not satisfy the commutative law, but satisfies the associative law, so
Finally, the transformation matrix for a point in 3D space looks like this:
4. Others
In the development of C# for Grasshopper, objects have scale and rotation methods, but often there is no translation method, because the coordinates at this time are stored in float3, so it is difficult to perform translation transformation. At this time, it is necessary to define a variable (generally var xf), and write all transformation operations in a Transform for application. This is the principle.
References:
[1] GAMES101-Introduction to Modern Computer Graphics-Yan Lingqi_哔哩哔哩_bilibili