Graphics (INFOGR), 2018-19, Block IV, lecture 8 Deb Panja
Today: Matrices and introduction to transformations
Welcome back!
1
Welcome back! 1 Today Matrices: why and what? Matrix operations - - PowerPoint PPT Presentation
Graphics (INFOGR), 2018-19, Block IV, lecture 8 Deb Panja Today: Matrices and introduction to transformations Welcome back! 1 Today Matrices: why and what? Matrix operations Determinants Adjoint/adjugate and inverse of matrices
Graphics (INFOGR), 2018-19, Block IV, lecture 8 Deb Panja
1
Today
2
Spatial transformations − part II of the course
3
Spatial transformations − part II of the course
− you need to execute such spatial transformations (a lot!) − matrices are the vehicles you need for these tasks
4
Spatial transformations − part II of the course
− you need to execute such spatial transformations (a lot!) − matrices are the vehicles you need for these tasks
transformations they achieve
5
Bigger scheme of things: three upcoming maths lectures
6
Bigger scheme of things: three upcoming maths lectures
7
Bigger scheme of things: three upcoming maths lectures
8
What is a matrix?
9
What is a matrix?
10
What is a matrix?
11
Why matrices?
(more about that in the next lecture)
12
Matrices
13
Matrices
− when m = n, the matrix is called a square matrix − aij (i ∈ [1, m], j ∈ [1, n]) are the matrix elements/coefficients − shorthand notation A = {aij}
14
Matrices
− when m = n, the matrix is called a square matrix − aij (i ∈ [1, m], j ∈ [1, n]) are the matrix elements/coefficients − shorthand notation A = {aij}
− an m×n matrix: n vertical concatenation of m-dimensional vectors
15
Matrices
− when m = n, the matrix is called a square matrix − aij (i ∈ [1, m], j ∈ [1, n]) are the matrix elements/coefficients − shorthand notation A = {aij}
− an m×n matrix: n vertical concatenation of m-dimensional vectors
16
Special matrices
for i = j; e.g., (a diagonal matrix is by definition a square matrix)
17
Special matrices
for i = j; e.g., (a diagonal matrix is by definition a square matrix)
(denoted by I, an identity matrix is also by definition a square matrix)
18
Special matrices
for i = j; e.g., (a diagonal matrix is by definition a square matrix)
(denoted by I, an identity matrix is also by definition a square matrix)
19
20
Addition of matrices
21
Addition of matrices
22
Scalar multiplication of matrices
23
Addition and scalar multiplication of matrices
24
Subtraction of matrices
− e.g., (can only subtract matrices of same dimensions!)
25
Matrix multiplication
then C = AB is an m × p-dimensional matrix
26
Matrix multiplication
then C = AB is an m × p-dimensional matrix
n
aikbkj
e.g.,
27
Vector dot product as a matrix multiplication
u = u1 u2 . . ud and v = v1 v2 . . vd
v = [u1 u2 . . . ud] v1 v2 . . vd = v · u = u1v1 + u2v2 + . . . + udvd
28
Matrix multiplication properties
however, AB = BA if both A and B are diagonal in particular, IA = AI = A and AØ = ØA = Ø
29
Transpose of a matrix
30
Transpose of a matrix
31
32
Determinants
33
Determinant (1 × 1 matrices)
e.g., A = [−5], det(A) = −5
34
Determinant (2 × 2 matrices)
a12 a21 a22
35
Determinant (2 × 2 matrices)
a12 a21 a22
36
Determinant (2 × 2 matrices)
a12 a21 a22
= a11 cof(a11) + a21 cof(a21)
37
Determinant (2 × 2 matrices)
a12 a21 a22
= a11 cof(a11) + a21 cof(a21) = a12 cof(a12) + a22 cof(a22)
38
Determinant (2 × 2 matrices)
a12 a21 a22
cof(aij) = (−1)i+j det(minor(aij)) minor(aij) is the matrix without the i-th row and j-th column of A
39
Determinant (2 × 2 matrices)
a12 a21 a22
cof(aij) = (−1)i+j det(minor(aij)) minor(aij) is the matrix without the i-th row and j-th column of A
det(A) = a11a22 − a12a21; note also that det(A) = det(AT)
40
Determinant (3 × 3 matrices)
a11 a12 a13 a21 a22 a23 a31 a32 a33 det(A) = a11 cof(a11) + a12 cof(a12) + a13 cof(a13)
41
Determinant (3 × 3 matrices)
a11 a12 a13 a21 a22 a23 a31 a32 a33 det(A) = a11 cof(a11) + a12 cof(a12) + a13 cof(a13) = a21 cof(a21) + a22 cof(a22) + a23 cof(a23)
42
Determinant (3 × 3 matrices)
a11 a12 a13 a21 a22 a23 a31 a32 a33 det(A) = a11 cof(a11) + a12 cof(a12) + a13 cof(a13) = a11
a23 a32 a33
a23 a31 a33
a22 a31 a32
+ a13a21a32 − a13a22a31 = det(AT)
43
Determinant (3 × 3 matrices), Sarrus’ rule
44
Determinant (3 × 3 matrices), Sarrus’ rule
45
46
Cofactor matrix and adjoint/adjugate
i.e., cij = cof(aij) example:
47
Inverse of a matrix
|A|
48
49
Determinants of 2 × 2 matrices
a12 a21 a22
and the two vectors u =
a21
v =
a22
u, v) Oriented area is positive if u to v requires a counterclockwise rotation. Otherwise oriented area is negative.
50
Determinants of 3 × 3 matrices
a11 a12 a13 a21 a22 a23 a31 a32 a33 , and the three vectors u = a11 a21 a31 , v = a12 a22 a23 and w = a13 a23 a33 then det(A) is the oriented volume of the parallelepiped formed by ( u, v, w) Oriented volume is positive if ( u, v, w) forms a right-handed co-ordinate system. Otherwise
51
Determinants of 3 × 3 matrices
a11 a12 a13 a21 a22 a23 a31 a32 a33 , and the three vectors u = a11 a21 a31 , v = a12 a22 a23 and w = a13 a23 a33 then det(A) is the oriented volume of the parallelepiped formed by ( u, v, w) Oriented volume is positive if ( u, v, w) forms a right-handed co-ordinate system. Otherwise
u, v, w)’s handedness?
52
Cross product and handedness of a co-ordinate system
x × ˆ y = ˆ z, ˆ y × ˆ z = ˆ x, ˆ z × ˆ x = ˆ y i.e., (ˆ x × ˆ y) · ˆ z > 0 etc. (this is what we will use)
x × ˆ y = −ˆ z, ˆ y × ˆ z = −ˆ x, ˆ z × ˆ x = −ˆ y i.e., (ˆ x × ˆ y) · ˆ z < 0 etc.
53
Determinants of 3 × 3 matrices
a11 a12 a13 a21 a22 a23 a31 a32 a33 , and the three vectors u = a11 a21 a31 , v = a12 a22 a23 and w = a13 a23 a33 then det(A) is the oriented volume of the parallelepiped formed by ( u, v, w) Oriented volume is positive if ( u, v, w) forms a right-handed co-ordinate system. Otherwise
u, v, w)’s handedness?
u × v) · w is > < 0
54
Determinants of n × n matrices
a11 a12 a13 . . . a21 a22 a23 . . . a31 a32 a33 . . . . . . . . . . . . . . . , and the vectors u1 = a11 a21 a31 . . . , u2 = a12 a22 a23 . . . , u3 = a13 a23 a33 . . . , . . . then det(A) is the oriented volume of the n-dimensional parallelepiped
u3 = λ u1 + µ u2?
55
Determinants of n × n matrices
a11 a12 a13 . . . a21 a22 a23 . . . a31 a32 a33 . . . . . . . . . . . . . . . , and the vectors u1 = a11 a21 a31 . . . , u2 = a12 a22 a23 . . . , u3 = a13 a23 a33 . . . , . . . then det(A) is the oriented volume of the n-dimensional parallelepiped
u3 = λ u1 + µ u2?
56
57
Remember...
58
Remember...
− use them to project, scale, reflect, shear, rotate.... objects (objects means objects one point at a time)
[point (x, y, z) represented as vector x y z drawn from the origin]
59
That brings us to... active vs. passive transformations
60
That brings us to... active vs. passive transformations
point transformation co-ordinate transformation (aka active transformation) (aka passive transformation)
61
62
63
Translation: a matrix operation?
i.e., x′ = x + ax, y′ = y + ay, z′ = z + az
[think of using (x, y, z) as a vector v from the origin]
64
Translation: a matrix operation
i.e., x′ = x + ax, y′ = y + ay, z′ = z + az A. x′ y′ z′ 1 = 1 ax 1 ay 1 az 1
a)
x y z 1 ; a = ax ay az
65
Translation: a matrix operation
i.e., x′ = x + ax, y′ = y + ay, z′ = z + az A. x′ y′ z′ 1
= 1 ax 1 ay 1 az 1
a)
x y z 1
extended vector
; a = ax ay az
i.e., we add a fictitious dimension, meaning: ˆ x = 1 , ˆ y = 1 , ˆ z = 1 , ˆ f = 1
66
How to think about an extended vector for 2D
v, by construction, satisfies v · ˆ f = 0 e.g., the (2+1)D representation of a real vector in 2D is vx vy
67
Summary
− matrix dimensions, special matrices (diagonal, identity, null)
matrix multiplication, transpose)
− translation and the fictitious coordinate
68
Finally, references...
69