Essential reading 06 shader Getting the foundations of mathematics notes

Chapter IV mathematical basis

First, the coordinate system is
a Cartesian coordinate system, divided into 2D and 3D.
OpenGL is a two-dimensional coordinate system for the lower left corner of 0, DirectX is the top left corner.
Three-dimensional coordinate system, three coordinate axes are also referred to as base vectors, basis vectors of length 1 is called an orthonormal basis, orthogonal base length is not the only call 1.
Three-dimensional Cartesian coordinate system is divided into left-handed and right-handed coordinate system.
Unity is a left-handed use, the camera view volume is right-handed coordinate system (camera in front of the z-axis negative direction).

Second, the vector point and
the vector: molding direction have no position.
Point: just a location.

Vector arithmetic operations, modulo operations.

Unit vector: vector is normalized. By adding the above vector of the vector ^ are represented mold.
The calculation unit vector: vector magnitude is calculated by dividing the vector.
Vector calculating unit generally used in the normal direction, the direction of the light source and the like.

Vector dot product (dot product / dot):
dot product of the direction can be determined is the relationship between two vectors. = Scalar projected length.
Results dot> 0: two vector directions relationship <90 °. (= 0: vertical, <0:> 90 °)
required amount can be molded vector dot product of its own, the square root operation.
a · b = | a || b | cos angle

Vector cross product (the outer product / cross product):
cross product result is a vector, is not commutative, the result was a cross product of these two vectors simultaneously new vector perpendicular.
Using the left hand, right-hand rule to determine the vector direction in the different coordinate systems, newly obtained.
| a × b | = | a || b | sin angle

We can determine the angle between two vectors by the relationship of a dot (cos value).
Analyzing may also be a front surface of the back by a cross product (determined by determining the three points of the surface of the clockwise, counterclockwise, clockwise counterclockwise judged necessary by the new Z-axis vector of the cross product is positive or negative is determined )

Third, the matrix

Row, column,
row matrix, column vector matrix can be replaced, in the space vector transformation would allow participation like a matrix, the matrix operation.

1. The matrix operation
matrix scalar multiplication:
coming of each element of the matrix, and scalar multiplication.

Matrix multiplication of the matrix:
matrix multiplication is required, the same number of columns and rows of a matrix have a further matrix.
I will want to take to get a new matrix, the dimension of the new matrix (4 × 5 5 × 6 matrix multiplication matrix)
Results of 4 × 6 matrix.
AB Operation: for each result Cij is the number of matrix, A, to find the i-th row and j-th column of B, after finding the corresponding elements, and then adding the multiplied.
Matrix multiplication is not commutative. AB = BA
matrix multiplication is associative. (AB) C = A (BC )

2. Special Matrices

Block matrix:
i.e. square matrix most commonly used in the 3D rendering is in the 3 × 3,4 × 4.
Diagonal elements: refers to the row number and column number of the square equal elements.
Diagonal matrix: in addition to a square diagonal elements are zero, then this works square diagonal matrix.

Matrix:
the diagonal elements are the diagonal matrix is a matrix of any matrix multiplication with the same results.

Transposed matrix:
transposed matrix is a matrix operation on the original, i.e., a transpose operation (A T representative of the upper right corner transpose of A).
Property 1: The matrix transpose is equal to the original matrix transpose.
Nature 2: matrix transpose equals the reverse series connected in series each transposed matrix.
(AB) .T = BT AT ( .T meaning upper right corner of the letter)

Inverse matrix:
Only have the inverse square.
Original matrix inverse matrix multiplication is 1.
Top right inverse matrix is represented by -1.
A matrix has an inverse matrix then the matrix is reversible, non-singular.
And determining the inverse matrix method for finding the library may be used.
Property 1: inverse matrix inverse matrix is a matrix itself.
Property 2: inverse matrix is his own.
Nature 3: transposed matrix transpose is the inverse matrix of the inverse matrix.
Property 4: Matrix inverse matrix obtained by multiplying the series is equal to the inverse matrix of each cascaded inverse matrix.

Orthogonal matrix:
refers to the product of a matrix and a transposed matrix of his identity matrix. Then the matrix is called orthogonal.
In other words, if a matrix is orthogonal, then it's transposed matrix and inverse matrix is the same.
That ---- MT = M.-1
in three-dimensional transformation, we often use the inverse matrix to solve the inverse transform, so we may use identity orthogonal matrix obtained by the transposed matrix.
The matrix is then how to determine whether an orthogonal matrix:
Condition 1: Each row of the matrix, i.e., vector elements are internal unit vector.
Condition 2: each row of the matrix, i.e. between the individual need vector elements are mutually perpendicular.
Condition 3: The above two conditions are equally applicable to each column vector of the matrix elements.
Transposed orthogonal matrix is an orthogonal matrix. ,
Orthonormal basis can accurately satisfy the above condition.
Orthogonal basis: coordinate space basis vectors need exists, axes perpendicular to each other and these base vectors.
Orthonormal basis: when the length of the base vectors 1.

When a vector matrix multiplication, it is necessary to consider the issue rank vector of the matrix.
Because matrix multiplication is conditional meet before they can multiply. (Several odd row)
Unity conventional practice is a vector on the right side matrix, the column vector conversion matrix is calculated.
For example: CBAv = (C (B ( Av))), read right to left, and the first v A, and then B, C.

Several features noted matrix multiplication:
AB.T = (BA.T) .T
If B is a symmetric matrix, row and column matrix multiplication matrix multiplication of each other thanks to a transposed matrix.

Wuhan Come on! Chinese New Year at home have to refuel Ha!

发布了16 篇原创文章 · 获赞 3 · 访问量 3071

Guess you like

Origin blog.csdn.net/w9503/article/details/103407218