The role of a model view projection matrix is to transform vertices from a local coordinate system into a canonical cube (Canonical view volnme). In summary, the model view projection matrix = projection matrix x view matrix X model matrix, the model matrix transforms vertices from the local coordinate system into the world coordinate system, the view matrix transforms the vertices from the world coordinate system into the view coordinate system, and the projection matrix transforms the vertices from the view coordinate system into the specification cube.
As shown in the following illustration, suppose you are now rendering triangles in three-dimensional space to the screen. In the triangle's model file, the vertex coordinates are in the local coordinate system (XL-YL-ZL), such as the initial coordinates of the three vertices of the triangle may be (1,0,0), (0,1,0), (0,0,1).
Model Matrix
The model matrix transforms the vertex coordinates under the local coordinate system into the world coordinate system. This involves the position and direction of the local coordinate system relative to the world coordinate system , or how the coordinates change when the position of the points in the space changes.
Consider three basic transformations: pan, rotate, and zoom.
The meaning of "transformation" is to map the coordinates p of the initial position of a point to the position coordinate p ' after translation, rotation, and scaling, i.e.:
⎡⎣⎢xyz⎤⎦⎥→⎡⎣⎢x′y′z′⎤⎦⎥
The translation transformation is the simplest transformation:
⎡⎣⎢x′y′z′⎤⎦⎥=⎡⎣⎢xyz⎤⎦⎥+⎡⎣⎢txtytz⎤⎦⎥
The rotation transformation is somewhat complex, looking at the rotation of the two-dimensional plane first:
It's easy to get:
x′=xcosθ−ysinθy′=xsinθ+ysinθ
The expression in matrix form is more concise:
[X′y′]=[cosθsinθ−