Professional Documents
Culture Documents
Course: Next Steps: Foundations of Computer Graphics
Course: Next Steps: Foundations of Computer Graphics
Vectors and Dot Products § First few lectures core math ideas in graphics
§ This lecture is a revision of basic math concepts
a
X
( )
⎛ x ⎞
A = ⎜ ⎟
T
A = x y A = x2 + y 2
§ Geometrically: Parallelogram rule ⎝ y ⎠
§ In cartesian coordinates (next), simply add coords § X and Y can be any (usually orthogonal unit) vectors
1
Vector Multiplication Dot (scalar) product
b
§ Dot product
§ Cross product φ
§ Orthonormal bases and coordinate frames a
aib = bia = ?
§ Note: We use right-handed (standard) coordinates
φ φ
a a
⎛ x ⎞ ⎛ x ⎞
a
ab = ⎜ ⎟ ⎜ b ⎟ = xa xb + y a y b
⎜⎝ y a ⎟⎠ ⎜⎝ y b ⎟⎠
2
Dot product: some applications in CG Projections (of b on a)
b
§ Find angle between two vectors (e.g. cosine of angle
between light source and surface for shading)
φ
a
§ Finding projection of one vector on another (e.g.
aib
coordinates of point in arbitrary coordinate system) b → a = b cosφ =
b→a =? a
§ Advantage: computed easily in cartesian components b→a =? a aib
b→a= b→a = 2
a
a a
Vector Multiplication
Foundations of Computer Graphics § Dot product
Online Lecture 2: Review of Basic Math § Cross product
Vectors: Cross Products § Orthonormal bases and coordinate frames
3
Cross product: Cartesian formula? Cross product: Cartesian formula?
x y z ⎛ y z −y z ⎞
⎜ a b b a
⎟
a × b = xa y a za = ⎜ za xb − xa zb ⎟
⎜ ⎟
xb y b zb ⎟⎠
⎜⎝ xa y b − y a xb
⎛ 0 −z y a ⎞ ⎛ xb ⎞
a
⎜ ⎟⎜ ⎟
a × b = A*b = ⎜ za 0 −xa ⎟ ⎜ y b ⎟
⎜ ⎟⎜ ⎟
⎜⎝ −y a xa 0 ⎟⎠ ⎜⎝ zb⎟⎠
Dual matrix of vector a
Vector Multiplication
Foundations of Computer Graphics § Dot product
Online Lecture 2: Review of Basic Math § Cross product
Vectors: Orthonormal Basis Frames § Orthonormal bases and coordinate frames
Ravi Ramamoorthi
§ Note: We use right-handed (standard) coordinates
4
Constructing a coordinate frame Constructing a coordinate frame?
§ Often, given a vector a (viewing direction in HW1), want to We want to associate w with a, and v with b
construct an orthonormal basis § But a and b are neither orthogonal nor unit norm
§ And we also need to find u
§ Need a second vector b (up direction of camera in HW1)
§ Construct an orthonormal basis (for instance, camera
coordinate frame to transform world objects into in HW1)
5
Matrices What is a matrix
§ Can be used to transform points (vectors) § Array of numbers (m×n = m rows, n columns)
§ Translation, rotation, shear, scale
(more detail next lecture) ⎛ 1 3 ⎞
⎜ ⎟
⎜ 5 2 ⎟
⎝ 0 4 ⎠
§ Addition, multiplication by a scalar simple:
element by element
⎛ 1 3 ⎞ ⎛ 1 3 ⎞ ⎛ 9 27 33 13 ⎞
⎜ ⎟⎛ 3 6 9 4 ⎞ ⎜ ⎟⎛ 3 6 9 4 ⎞ ⎜ ⎟
⎜ 5 2 ⎟ ⎜⎝ 2 7 8 3 ⎟⎠ ⎜ 5 2 ⎟ ⎜⎝ 2 7 8 3 ⎟⎠ = ⎜ 19 44 61 26 ⎟
⎝ 0 4 ⎠ ⎝ 0 4 ⎠ ⎝ 8 28 32 12 ⎠
§ Element (i,j) in product is dot product of row i of first § Element (i,j) in product is dot product of row i of first
matrix and column j of second matrix matrix and column j of second matrix
§ Element (i,j) in product is dot product of row i of first § Element (i,j) in product is dot product of row i of first
matrix and column j of second matrix matrix and column j of second matrix
6
Matrix-matrix multiplication Matrix-Vector Multiplication
§ Number of columns in first must = rows in second § Key for transforming points (next lecture)
⎛ 1 3 ⎞
⎛ 3 6 9 4 ⎞⎜ ⎟ § Treat vector as a column matrix (m×1)
⎜ ⎟ 5 2 NOT EVEN LEGAL!!
⎝ 2 7 8 3 ⎠ ⎜⎝ 0 4 ⎟⎠
§ Non-commutative (AB and BA are different in general) § E.g. 2D reflection about y-axis
§ Associative and distributive ⎛ −1 0 ⎞ ⎛ x ⎞ ⎛ −x ⎞
§ A(B+C) = AB + AC ⎜ ⎟⎜ ⎟ =⎜ ⎟
§ (A+B)C = AC + BC ⎝ 0 1 ⎠⎝ y ⎠ ⎝ y ⎠
⎛ 1 0 0 ⎞
T
⎛ 1 2 ⎞
⎜ ⎟ ⎛ 1 3 5 ⎞
⎜ 3 4 ⎟ = ⎜⎝ 2 4 6 ⎟⎠ ⎜ ⎟
⎝ 5 6 ⎠
I3×3 =⎜ 0 1 0 ⎟
⎝ 0 0 1 ⎠
(AB)T = BT AT
AA−1 = A−1A = I
(AB)−1 = B −1A−1
(x )
⎜ b ⎟
a
ya za (
⎜ y b ⎟ = xa xb + y a y b + za zb )
⎜ ⎟
⎜⎝ zb ⎟⎠
⎛ 0 −za y a ⎞ ⎛ xb ⎞
*
⎜ ⎟⎜ ⎟
§ Cross product? a × b = A b = ⎜ za 0 −xa ⎟ ⎜ y b ⎟
⎜ ⎟⎜ ⎟
⎜⎝ −y a xa 0 ⎟⎠ ⎜⎝ zb ⎟⎠
Dual matrix of vector a