This is the 21st day of my participation in the December Gwen Challenge. Check out the event details: The last Gwen Challenge 2021

Linear algebra is the mathematical foundation of graphics.

vector

The vector represents the direction plus the length.

A unit vector is a vector divided by a length, and it only goes in one direction.

Vector calculation

You can add the heads of two vectors, you can add the heads of two vectors.

There are two kinds of vector multiplication, dot and cross.

The dot product is the value of two vectors times cosine of the Angle between them; In Cartesian coordinates, it’s also equal to the sum of the products of each of the vectors. And this is useful, given two vectors, you know their dot product, and you know the length of each vector, and you can figure out the Angle between them.

You get the Angle between the two vectors. You can also figure out the projection of one vector onto another vector, and you get that from the Angle between them. A projection can split a vector into two vectors. You can also figure out the relationship between the angles of two vectors, the same/opposite direction.

The cross product of a vector, mainly to get a vector that is perpendicular to the original vector, is the sine of two lengths times the Angle of the two vectors, and the direction is usually given by the right hand spiral rule.

The figure above is the representation of the cross product in algebra/matrix.

The cross product

  • A cross b, z is positive, b is to the left of A, z is negative, b is to the right of A

  • Ab, AP, BC, bp, Ca, cp. If p is on the left, then P is inside the triangle. Can be used to determine whether a pixel is inside or outside the shader.

matrix

A matrix is a set of numbers in a row, and as we’ve seen, it’s a very convenient representation of vectors.

Matrix multiplication, (MN) (NP)= (M*P), does not satisfy the commutative law, binding rate and distributive law.

The relationship between matrix and vector is shown above, that is, there is a one-to-one correspondence between matrix and vector.

The identity matrix is a special kind of matrix, any matrix times the identity matrix is itself, and the product of matrix A and matrix B is the identity matrix, so we say that these two matrices inverse each other.

The rank of matrix is a special algorithm of matrix.

conclusion

As you can see, graphics doesn’t require a lot of mathematical foundation, it requires us to have a basic understanding of vectors and matrices. Among them, the dot product and cross product of vectors are very important concepts, which have very practical uses and need special attention.

This article is from games101, if you’re interested. www.bilibili.com/video/BV1X7…