Lingheng Tao
Shader#1 Math Reviews (I)
#Shader #GameEngine #Unity3D #ComputerGraphics
This blog writes about some basic maths that will be used in the implementation of shaders.
§1.1 Coordinate System
Some concepts:
Orthonormal basis: 3 basis vectors that are perp to each other; the length of each is 1.
Orthogonal basis: 3 basis vectors that are perp to each other, whose lengths are not necessarily 1.
Handed Coordinate Space: left-handed c.s. vs. right-handed c.s. ALWAYS, your thumb is pointing to +x, and your index finger is pointing to +y.

4. Positive rotation: in the handed system, use your corresponding hand; thumbs up along the direction of the axis, then the rotation of the remaining 4 fingers defines the positive direction of rotation.
Note: Unity uses the left-handed coordinate system, where right, up, and forward corresponds to +x, +y, and +z. i.e. the camera is facing to the negative direction of z-axis.
§1.2 Vector
Some concepts:
A 3D vector has form a = (x, y, z), 0 = (0,0,0).
Scalar times Vector
ba = b(x, y, z) = (bx, by, bz).
b can be any scalar.
Vector plus Vector
a = (a1, a2, a3), b = (b1, b2, b3), a+b = (a1+b1, a2+b2, a3+b3)
a - b = a + (-1)b.
Magnitude
|a| = sqrt(x^2 + y^2 + z^2).
Normalized vector ^v = v/|v|, where v is not 0. The normalized vector always has length(magnitude) 1.
Dot product
a = (a1, a2, a3), b = (b1, b2, b3), a·b = (a1b1, a2b2, a3b3)
a·b = |a||b|cos<a,b>, where <a,b> is the angle between a and b.
Geometric understanding: ^a · b is the signed projection of b on ^a.
Cross product
a = (a1, a2, a3), b = (b1, b2, b3), a×b = (a2b3 - a3b2, a3b1 - a1b3, a1b2-a2b1).
a × b = -b × a.
|a×b| = |a||b|sin<a, b>. It is the area of the parallelogram constructed by the 2 vectors.