preface

This is as a basic piece of graphics, review the basic knowledge of linear algebra, introduce the use of vectors, matrix usage and so on. Learning linear algebra is the best way to get to the bottom of graphics.

Graphics Series:

  • Graphics 01 – Awesome vector and linear algebra
  • Graphics 02 – Weird 2D and 3D transformations
  • Graphics 03 – Challenge view, Projection transformation demon

Vectors

The characteristics of

  • The vector represents the length and direction;
  • There is no absolute starting position;
  • Unit vector (direction only)

Vector sum

  • Geometrically: parallelogram rule, triangle rule;
  • Algebraic: simply add up the coordinates;

Vector multiplication

Dot product

When both vectors are unit vectors, unit 1, so the product of the two vectors is equal to the cosine of the Angle between them.

The dot product features

Cartesian coordinate system

  • X and Y are usually defined as unit vectors;
  • Graphically, it is common to default a vector to be a column vector (a column of numbers) so that all vectors can be left multiplied;

Cartesian coordinates dot product

Components multiply and then add

The dot product of the graph

  • Find the Angle between two vectors (e.g. the cosine of the Angle between the light source and the surface)
  • What does it look like to find a projection of a vector onto another vector
  • Measure the proximity of the two directions
  • Determine forward/backward

The dot product projection

Vector multiplication – cross product (cross product)

  • The cross product of the two initial vectors, you compute another vector, which is perpendicular to both of the initial vectors
  • The direction is determined by the right hand rule.
  • The cross product of vectors creates cartesian coordinates in three dimensions
  • The cross product of vectors does not satisfy the commutative law

Properties:

Cross product formula:

Cross product action:

  • Decide left or right
  • Decide inside and out

B is to the left of A. B is to the left of a

In the right figure, how to determine whether point P is inside the triangle ABC?

Methods: Based on cross product of the same direction vector

Orthogonal coordinate system

Any set of 3 vectors (3D)

matrix

In graphics, it is commonly used to represent transformations – translation, rotation, clipping, scaling.

What is a matrix

Array of numbers (m × n = m rows, N columns)

It involves matrix addition, multiplication.

Matrix addition: adding one element at a time.

Matrix multiplication

Satisfy the condition that the number of columns in A must equal the number of rows in B

(M x N)(N x P) = (M x P)

Results:

The element that comes from the dot product of row I of A and the column of B, so 26 on the right, which is in the second row, fourth column, 26 is going to come from the dot product of the second row and the fourth column on the left.

Product of matrices

Properties:

  • There is no commutative law (AB and BA are usually different)
  • Associative property and distributive property
    • (AB)C= A(BC)
    • A(B+C) = AB + AC
    • (A+B)C = AC + BC

Matrix and vector multiplication

• Think of vectors as column matrices (m by 1) • Key to transformation points (next lecture)

Transpose of the matrix

Toggle rows and columns (ij -> ji)

Properties:

Note: If you take the transpose of two matrices, you take the transpose of the last matrix, and then you take the transpose of the previous matrix

The inverse of the identity matrix (diagonal matrix) and the matrix

Vector multiplication can be written in matrix form

  • Dot product

  • cross-product