Unity matrix matrices

Source: Internet
Author: User

Linear algebra

4x4 Unit matrix

The 4*4 matrix represents 4 rows and 4 columns:

Transpose of matrix: the new matrix obtained by replacing the line of matrix A with the column of the same ordinal is called a transpose matrix, which is called the transpose of the Matrix.

Inverse matrix: Set A is an n-order matrix on a number of fields, if there is another n-order array B on the same number field, it makes: ab=ba=e. Then we call B a inverse matrix, and a is called a reversible matrix.

Multiplication of matrices: multiplication of two matrices can be defined only if the number of columns of the first matrix A is equal to the number of rows of another matrix B. If A is mxn matrices and B is nxp matrices, their product C is a mxp Matrix

, an element of it: And this product is recorded as:  The principle of calculation: the number of each row multiplied by the number of each column = equals the product of the element. To test the Unity matrix:

Results:

From the output you can see that the unity matrix uses the matrix left multiplication, that is, the vector is represented by a column vector, and precisely because the 16 elements of the matrix (M[i]:i represents 0~15) precede the first column, then the second column, the third column, and the fourth column.

row rows; Cloum columns.

Row matrix: A matrix of only one row, generally using the right multiplication in the matrix.

example, the matrix is multiplied by the 4x4 matrix and the result is a 1*4 matrix.

Column matrix: Only one column of the matrix, generally in the matrix using the left multiply,

example, the 4x4 matrix is multiplied by the vector and the result is a matrix of 4x1.

Unity Shader

In the vertex function functions, the vertex of the model space is converted to the projection space, o.pos = Mul (UNITY_MATRIX_MVP, V.vertex) , and the vertex vector is the column vector, which is understood as a matrix Use homogeneous coordinates to get the 4x1 matrix.

Turn the normal vector into world space

The transition of vertices from model space to world coordinate space only needs to be multiplied by the world transformation matrix, but the normals of the vertices cannot be transformed into world space by multiplying the matrix directly. The reason is that the world matrix contains not only rotation, but also the scaling operation, if the model is scaled disproportionately, with varying degrees of stretching or compression in different directions, the coordinates of the vertices will stretch, but if the normal vector is equally stretched, then the changed normal vector will no longer be perpendicular to the corresponding surface. Therefore, there is no scaling or scaling of the world transformation matrix, you can directly adopt the same transformation matrix as a normal vector transformation matrix.

Unity matrix matrices

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.