Loading [MathJax]/jax/output/CommonHTML/jax.js

The Notes of Computer Graphics Ⅱ

 

A swift and brutal review of Linear Algebra

Computer Graphics’ Dependencies

  • Basic mathematics
    • Linear algebra
    • Calculus
    • Statistics
  • Basic physics
    • Optics (Advanced: if we could not suppose the light travels in straight lines but interacts with a surface material in a form of light wave?)
    • Mechanics
  • Misc.
    • Signal processing (for anti-alias)
    • Numerical analysis (rendering is to find a solution of calculus defined by recursion, simulation is to solve FEA, Finite Element Analysis, or diffusion equation)
  • A bit of aesthetics

Vector

  • Direction and length
  • Usually written as a or using start and end point AB
  • No absolute starting position

Vector Normalization

  • Magnitude (length) of a vector written as |a|
  • Unit vector
    • A vector with length of 1
    • ˆa=a/|a|
    • represent directions

Vector Addition

  • Geometrically: Parallelogram law & Triangle law
  • Algebraically: Simply add coordinates

Dot (scalar) Product

ab=|a||b|cosθ

For unit vectors:

cosθ=ˆaˆb

Some properties:

ab=ba

a(b+c)=ab+ac

(ka)b=a(kb)=k(ab)

For component-wise multiplication of vectors in Cartesian coordinates:

ab=(xayaza)(xbybzb)=xaxb+yayb+zazb

Four common usages of dot product:

  1. To find angle between two vectors
  2. To find projection of one vector on another:

    To Calculate b: projection of b onto a

    • b must be along a, thus b=kˆa
    • The magnitude of k is |b|=|b|cosθ
  3. To measure how close two directions are
  4. To decompose a vector: b, b, bb

Cross Product

|a×b|=|a||b|sinϕ

  • Cross product is orthogonal to two initial vectors
  • Direction determined by right-hand rule
  • To construct coordinate systems

Some properties:

a×b=b×a

a×a=0

a×(b+c)=a×b+a×c

a×(kb)=k(a×b)

For cross product in Cartesian Formula:

a×b=(yazbybzazaxbxazbxaybyaxb)

Or using matrix form:

a×b=Ab=(0zayaza0xayaxa0)(xbybzb)

Two common usages of cross product:

cg-2-1

  1. To determine left/right: check if the cross product of two vectors points to the outside of the screen or out.
  2. To determine inside/outside: check if the cross product of AB×AP and BP×BP and CA×CP all directed to the outside of the screen.

Orthonormal Coordinate

We can decompose any vectors p by 3 unit vectors:

p=(pu)u+(pv)v+(pw)w
, where
|u|=|v|=|w|=1
uv=vw=uw=0
w=u×v

Matrix

  • 2D arrays that haunt in every CS course
  • In Graphics, pervasively used to represent transformations

Matrix-Matrix Multiplication

  • columns in A must = rows in B
  • Element (i, j) in the product is the dot product of row i from A and column j from B

Some properties:

  • Non-commutative: (AB and BA are different in general)
  • Associative and distributive:
    • (AB)C=A(BC)
    • A(B+C)=AB+AC

Matrix-Vecotr Multiplication

  • Treat vector as a column matrix (Mx1)
  • Treat vector as the right multiplier of the matrix (as a point)
  • Key for transforming points

Transpose of a Matrix

  • Switch rows and columns (ij to ji)
  • (AB)T=BTAT

Identity Matrix and Inverses

I3×3=(100010001)

AA1=A1A=I

(AB)1=B1A1

Reference

Gitalking ...