Review of linear algebra (notes)


Preface

Today I started to watch the computer graphics course of Games101. First, let’s review the address of the linear algebra
course: GAMES101-Introduction to Modern Computer Graphics-Yan Lingqi


1. Vectors

Vector : A
Insert picture description here
vector is an arrow from A to B, with direction and length. The vector does not care about its absolute position.

Magnitude : the length of the vector

Unit Vector Unit Vector : A vector of length 1, we don't care about its length but only its direction.

Vector summation : Insert picture description here
geometric addition is to connect vectors end to end, and algebraically add the coordinates of two vectors

Cartesian Coordinates (Cartesian Coordinates) :
Insert picture description here
In computer graphics, vectors are written in accordance with column writing by default, and A(T) is conversion

Dot product : Dot product
Insert picture description here
can easily get the angle (cosine) of two vectors, especially when both directions are unit vectors. It can also be used to calculate the projection of a vector on another vector.
Insert picture description here
The commutative law of dot product, associative law and distribution law
Insert picture description here
. Algorithm of dot product in Cartesian coordinate system.
Insert picture description here
Projection algorithm, the projection length is the length of the projection of the b vector on the a vector, and the direction is the direction of the a vector.
Insert picture description here
Projection can decompose a vector into a projection vector and a vector perpendicular to the projection vector.
Insert picture description here
The directionality of the two vectors can be judged by the sign of the dot product result. When the directions of the two vectors are exactly the same, the dot product result is 1 ( Unit vector), otherwise -1.

Cross product (Cross product) : The cross product
Insert picture description here
will get a new vector that is perpendicular to the original two vectors. The specific direction is determined by the right-hand rule (the four fingers of the right hand are from a to b, and the direction of the thumb is the direction of the cross product result vector. The directions of a b and b a are exactly opposite. Of course, the left-hand rule is used in some cases) . The cross product is useful when establishing a rectangular coordinate system, and can also be used to judge left and right (inside and outside).
Some boring formulas
Know the right-hand rule
Insert picture description here
. The cross product formula of vectors (Cartesian coordinate system) can be expressed by a matrix.
Insert picture description here
Use cross product to judge left and right. When a b, the z-axis of the result vector is positive, so judge b is on the left of a, when b a, the z-axis of the vector obtained is negative, so judge a is b To the right.
Use the cross product to judge the inside and outside, use AB cross multiply AP, get AP on the left side of AB, that is, P point on the left side of AB, BC cross multiply BP to get P on the left side of BC, CA cross multiply CP to get P The point is on the left side of CA, which means that P is inside the triangle ABC, because point P is always on the same side of the three sides.
Insert picture description here
A three-dimensional rectangular coordinate system can be established by dot product, and any vector can be decomposed into the projection of three coordinate system vectors (unit vectors). That is, the vector p is equal to calculating the corresponding projection length on the three coordinate system vectors, respectively multiplying the corresponding coordinate system vector itself, and then adding the three vectors.

Second, the matrix Matrices

Matrix : A Insert picture description herematrix is ​​a two-dimensional array (multidimensional), which is used to represent vector transformations in graphics. mxn means m rows and n columns.

Matrix multiplying matrix : Insert picture description hereMatrix multiplying matrix, first of all must be a matrix that can be multiplied, that is, the number of columns in the first matrix must be equal to the number of rows in the second matrix. The final result is a matrix with the number of rows in the first matrix and the number of columns in the second. (M x N)(N x P)=(M x P) The
value of the element (i, j) of the result matrix is ​​the result of the dot multiplication of the i-th row of the first matrix A and the j-th column of the second matrix B . For example, the element 26 in the second row and fourth column in the above figure is the result of (5, 2) multiplying (4, 3) 5 4+2 3.
Insert picture description here
Generally speaking, the matrix multiplication AB and BA are different, that is to say the matrix There is no commutative law, but the matrix satisfies the associative law and the distributive law.

Matrix and vector :
Insert picture description here
We treat a vector as a one-column matrix (a matrix of mx 1), and we can treat the matrix and vector as the same thing for matrix multiplication. Matrix multiplication can be used for vector transformation. In the above figure, a two-dimensional vector is mirrored and transformed according to the y axis (preview).

Transpose of the matrix (Transpose) :
Insert picture description here
Exchange rows and columns. Row i and column j become row j and column i, and column j becomes row j.
If two matrices are multiplied and then transposed, it is equivalent to multiplying the transposes of two matrices.

Identity Matrix :
Insert picture description here
A matrix with all 1s on the diagonal (Figure 3 by 3 matrix)

Inverses Matrix :
Insert picture description here
The result of multiplying a certain matrix and its inverse matrix is ​​an identity matrix.

The matrix form of vector multiplication :
Insert picture description here
the dot product of a vector can be transformed into the matrix transpose of a vector and multiplied by the b vector matrix.
The cross product of vectors can also be converted to matrix multiplication (a bit confused about what a dual matrix is).


Guess you like

Origin blog.csdn.net/qq_37856544/article/details/112793442
Recommended