Lecture 08a: MATRICES Sec 2.7
description
Transcript of Lecture 08a: MATRICES Sec 2.7
![Page 1: Lecture 08a: MATRICES Sec 2.7](https://reader036.fdocuments.us/reader036/viewer/2022062521/56814c7e550346895db99ba8/html5/thumbnails/1.jpg)
1Georgia Tech, IIC, GVU, 2006MAGIC MAGIC LabLab
http://www.gvu.gatech.edu/~jarek
Jarek Rossignac
Lecture 08a: MATRICESSec 2.7
Jarek Rossignac
CS1050: Understanding and CS1050: Understanding and Constructing Proofs Constructing Proofs Spring 2006Spring 2006
![Page 2: Lecture 08a: MATRICES Sec 2.7](https://reader036.fdocuments.us/reader036/viewer/2022062521/56814c7e550346895db99ba8/html5/thumbnails/2.jpg)
2Georgia Tech, IIC, GVU, 2006MAGIC MAGIC LabLab
http://www.gvu.gatech.edu/~jarek
Jarek Rossignac
Lecture Objectives
• Understand vectors, matrices, their products and properties.
• Illustrate these on linear transformations
![Page 3: Lecture 08a: MATRICES Sec 2.7](https://reader036.fdocuments.us/reader036/viewer/2022062521/56814c7e550346895db99ba8/html5/thumbnails/3.jpg)
3Georgia Tech, IIC, GVU, 2006MAGIC MAGIC LabLab
http://www.gvu.gatech.edu/~jarek
Jarek Rossignac
What do coordinates mean?• Let C be a coordinate system with origin o and basis (i, j)– i and j are unit length vectors orthogonal to each other
• Let point p have coordinates (x,y) in C• Define p in terms of x, y, o, i, j:
p = o + xi + yjstart at omake x steps in the i directionmake y steps in the j direction
ooii
jj
pp
xx
yy
![Page 4: Lecture 08a: MATRICES Sec 2.7](https://reader036.fdocuments.us/reader036/viewer/2022062521/56814c7e550346895db99ba8/html5/thumbnails/4.jpg)
4Georgia Tech, IIC, GVU, 2006MAGIC MAGIC LabLab
http://www.gvu.gatech.edu/~jarek
Jarek Rossignac
How do we represent points and vectors?
Using an ordered set of coordinates in an agreed-upon, yet not specified, global coordinate system
o = (xo, yo )i = ( xi , yi )j = ( xj , yj )p = ( xp , yp )
oo
iijj
pp
xx
yy
xo
yo
xi
yi
yp
xp
![Page 5: Lecture 08a: MATRICES Sec 2.7](https://reader036.fdocuments.us/reader036/viewer/2022062521/56814c7e550346895db99ba8/html5/thumbnails/5.jpg)
5Georgia Tech, IIC, GVU, 2006MAGIC MAGIC LabLab
http://www.gvu.gatech.edu/~jarek
Jarek Rossignac
Operations on points and vectors
• Subtracting two points yields a vector (displacement)
( xp , yp ) – ( xo , yo ) = ( xp– xo , po– yo )• Adding a vector to a point moves the point
( xo , yo ) + ( xj , yj ) = ( xo+xj , yo+yj )• Adding two vectors adds the corresponding coordinates
( xi , yi ) + ( xj , yj ) = ( xi+xj , yi+yj ) • Multiplying a vector by a scalar multiplies its length s( xi , yi ) = ( sxi , syi )
• The dot product of two vectors is the sum of the products of corresponding terms( xi , yi ) ( xj , yj ) = ( xi xj + yiyj )
![Page 6: Lecture 08a: MATRICES Sec 2.7](https://reader036.fdocuments.us/reader036/viewer/2022062521/56814c7e550346895db99ba8/html5/thumbnails/6.jpg)
6Georgia Tech, IIC, GVU, 2006MAGIC MAGIC LabLab
http://www.gvu.gatech.edu/~jarek
Jarek Rossignac
What is a matrix? • A scalar or ordered set of matrices
– scalars, vectors, mxn tables are matrices
For example (i , j , o ) is a 2x3 matrix often presented as a table
xi xj xo
yi yj yo==(i ,
j , o )
![Page 7: Lecture 08a: MATRICES Sec 2.7](https://reader036.fdocuments.us/reader036/viewer/2022062521/56814c7e550346895db99ba8/html5/thumbnails/7.jpg)
7Georgia Tech, IIC, GVU, 2006MAGIC MAGIC LabLab
http://www.gvu.gatech.edu/~jarek
Jarek Rossignac
What is a matrix-vector product?
Generalization of the dot product:
Sum of products of corresponding terms
(a , b , c )( x , y , z ) = ax+by+cz
![Page 8: Lecture 08a: MATRICES Sec 2.7](https://reader036.fdocuments.us/reader036/viewer/2022062521/56814c7e550346895db99ba8/html5/thumbnails/8.jpg)
8Georgia Tech, IIC, GVU, 2006MAGIC MAGIC LabLab
http://www.gvu.gatech.edu/~jarek
Jarek Rossignac
What is the matrix form of (xp,yp) ?
p = xi + yj + o = ( i , j , o ) ( x , y , 1 )
( xp , yp ) = x( xi , yi ) + y( xj , yj ) + ( xo , yo )
= ( xxi , xyi ) + ( yxj , yyj ) + ( xo , yo )
= ( xxi+yxj+xo , xyi+yyj+ yo ) xp
yp
xi xj xo
yi yj yo==
x
y
1
![Page 9: Lecture 08a: MATRICES Sec 2.7](https://reader036.fdocuments.us/reader036/viewer/2022062521/56814c7e550346895db99ba8/html5/thumbnails/9.jpg)
9Georgia Tech, IIC, GVU, 2006MAGIC MAGIC LabLab
http://www.gvu.gatech.edu/~jarek
Jarek Rossignac
What is the homogeneous representation?
• Add a third coordinate: 1 for points, 0 for vectors
o = (xo, yo , 1)i = ( xi , yi , 0)j = ( xj , yj , 0)p = ( xp , yp , 1)
![Page 10: Lecture 08a: MATRICES Sec 2.7](https://reader036.fdocuments.us/reader036/viewer/2022062521/56814c7e550346895db99ba8/html5/thumbnails/10.jpg)
10Georgia Tech, IIC, GVU, 2006MAGIC MAGIC LabLab
http://www.gvu.gatech.edu/~jarek
Jarek Rossignac
Homogeneous matrix form of (xp,yp) ?
p = xi + yj + o = ( i , j , o ) ( x , y , 1 )
( xp , yp , 1) = x( xi , yi , 0) + y( xj , yj , 0) + 1( xo , yo , 1)
= ( xxi+yxj+xo , xyi+yyj+ yo , 1 ) xp
yp
1
xi xj xo
yi yj yo
0 0 1==
x
y
1
![Page 11: Lecture 08a: MATRICES Sec 2.7](https://reader036.fdocuments.us/reader036/viewer/2022062521/56814c7e550346895db99ba8/html5/thumbnails/11.jpg)
11Georgia Tech, IIC, GVU, 2006MAGIC MAGIC LabLab
http://www.gvu.gatech.edu/~jarek
Jarek Rossignac
Performing the multiplication
• Multiply columns and add
xp
yp
1
xi xj xo
yi yj yo
0 0 1==
x
y
1
![Page 12: Lecture 08a: MATRICES Sec 2.7](https://reader036.fdocuments.us/reader036/viewer/2022062521/56814c7e550346895db99ba8/html5/thumbnails/12.jpg)
12Georgia Tech, IIC, GVU, 2006MAGIC MAGIC LabLab
http://www.gvu.gatech.edu/~jarek
Jarek Rossignac
How to compute (x,y) ?
o = (xo, yo ), i = ( xi , yi ), j = ( xj , yj ), p = ( xp , yp )
Let op = p – o x = op i y = op j
vi is the normalprojection of vectorv on the unit vector i
oo
iijj
pp
xx
yy
xo
yo
xi
yi
yp
xp
![Page 13: Lecture 08a: MATRICES Sec 2.7](https://reader036.fdocuments.us/reader036/viewer/2022062521/56814c7e550346895db99ba8/html5/thumbnails/13.jpg)
13Georgia Tech, IIC, GVU, 2006MAGIC MAGIC LabLab
http://www.gvu.gatech.edu/~jarek
Jarek Rossignac
How to extend this to 3D ?
o = (xo, yo , zo , 1)i = ( xi , yi , zi , 0)j = ( xj , yj , zj , 0)p = ( xp , yp , zp , 1)
pp
yp
xp
zp
(1,0,0)
(0,1,0)
(0,0,1)
![Page 14: Lecture 08a: MATRICES Sec 2.7](https://reader036.fdocuments.us/reader036/viewer/2022062521/56814c7e550346895db99ba8/html5/thumbnails/14.jpg)
14Georgia Tech, IIC, GVU, 2006MAGIC MAGIC LabLab
http://www.gvu.gatech.edu/~jarek
Jarek Rossignac
More general notation for matrices
A = [ aij ]rc
i is the row numberj is the column number
We say that A is an rc matrix if it has r rows and c columns
We say that an nn matrix is square.
In a square matrix, aii are the diagonal elements. Their sum aij is the trace of A
a11 a12 a13 a14
a21 a22 a23 a24
a31 a33 a33 a34
A34 =
![Page 15: Lecture 08a: MATRICES Sec 2.7](https://reader036.fdocuments.us/reader036/viewer/2022062521/56814c7e550346895db99ba8/html5/thumbnails/15.jpg)
15Georgia Tech, IIC, GVU, 2006MAGIC MAGIC LabLab
http://www.gvu.gatech.edu/~jarek
Jarek Rossignac
Operations for matrices
Equality: [ aij ]mn = [ bij ]mn when ij aij
= bij
Addition: [ aij ]mn + [ bij ]mn = [ aij + bij ]mn
Multiplication: [ aij ]mk [ bij ]kn = [ ai* b*j ]mn
ai* is a vector made from the row elements: (ai1 , ai2 ,…
aic)b*j is a vector made from the column elements: (b1j , b2j ,…
brj)
In general, matrix multiplication is not commutative AB≠BA
![Page 16: Lecture 08a: MATRICES Sec 2.7](https://reader036.fdocuments.us/reader036/viewer/2022062521/56814c7e550346895db99ba8/html5/thumbnails/16.jpg)
16Georgia Tech, IIC, GVU, 2006MAGIC MAGIC LabLab
http://www.gvu.gatech.edu/~jarek
Jarek Rossignac
What is the cost of matrix multiplication?
How many multiplications, additions are performed when multiplying two nn matrices?
We need to compute n2 dot productsEach one requires n multiplications and n–1 additions
Total: n3 multiplications and (n–1)n2
additions
![Page 17: Lecture 08a: MATRICES Sec 2.7](https://reader036.fdocuments.us/reader036/viewer/2022062521/56814c7e550346895db99ba8/html5/thumbnails/17.jpg)
17Georgia Tech, IIC, GVU, 2006MAGIC MAGIC LabLab
http://www.gvu.gatech.edu/~jarek
Jarek Rossignac
Best order for chain multiplication?
Matrix multiplication is associative:
((Akm Bmn)Cno)Dop = Akm((BmnCno)Dop)
Which order requires fewest multiplications?
(Akm Bmn) requires kmn multiplications (kn of m)
((Akm Bmn)Cno)Dop requires kmn+kno+kod
Akm((BmnCno)Dop) requires mno+mop+kmp
![Page 18: Lecture 08a: MATRICES Sec 2.7](https://reader036.fdocuments.us/reader036/viewer/2022062521/56814c7e550346895db99ba8/html5/thumbnails/18.jpg)
18Georgia Tech, IIC, GVU, 2006MAGIC MAGIC LabLab
http://www.gvu.gatech.edu/~jarek
Jarek Rossignac
What is the identity matrix?
In = [ ij ]nn where ii = 1 and ij = 0 when i≠jdiagonal terms are 1, the others 0
Property of identity: AmnIn = ImAmn= Amn
![Page 19: Lecture 08a: MATRICES Sec 2.7](https://reader036.fdocuments.us/reader036/viewer/2022062521/56814c7e550346895db99ba8/html5/thumbnails/19.jpg)
19Georgia Tech, IIC, GVU, 2006MAGIC MAGIC LabLab
http://www.gvu.gatech.edu/~jarek
Jarek Rossignac
What is the power of a square matrix?
Ann0 = In
Annk = AnnAnn … Ann (product of k
matrices)
![Page 20: Lecture 08a: MATRICES Sec 2.7](https://reader036.fdocuments.us/reader036/viewer/2022062521/56814c7e550346895db99ba8/html5/thumbnails/20.jpg)
20Georgia Tech, IIC, GVU, 2006MAGIC MAGIC LabLab
http://www.gvu.gatech.edu/~jarek
Jarek Rossignac
What is the transpose of a matrix?
[ aij ]mnt = [ aji ]nm
![Page 21: Lecture 08a: MATRICES Sec 2.7](https://reader036.fdocuments.us/reader036/viewer/2022062521/56814c7e550346895db99ba8/html5/thumbnails/21.jpg)
21Georgia Tech, IIC, GVU, 2006MAGIC MAGIC LabLab
http://www.gvu.gatech.edu/~jarek
Jarek Rossignac
When is a square matrix symmetric?
A is symmetric if A=At , i.e., ij aij = aji
A mirror reflection about the diagonal will not change the matrix.
![Page 22: Lecture 08a: MATRICES Sec 2.7](https://reader036.fdocuments.us/reader036/viewer/2022062521/56814c7e550346895db99ba8/html5/thumbnails/22.jpg)
22Georgia Tech, IIC, GVU, 2006MAGIC MAGIC LabLab
http://www.gvu.gatech.edu/~jarek
Jarek Rossignac
What are joins and meets of binary matrices?
Entries represent truth values (denoted 0 and 1 for simplicity)
The join of two Boolean matrices is
[ aij ]mn [ bij ]mn = [ aij bij ]mn
The meet of two Boolean matrices is
[ aij ]mn [ bij ]mn = [ aij bij ]mn
![Page 23: Lecture 08a: MATRICES Sec 2.7](https://reader036.fdocuments.us/reader036/viewer/2022062521/56814c7e550346895db99ba8/html5/thumbnails/23.jpg)
23Georgia Tech, IIC, GVU, 2006MAGIC MAGIC LabLab
http://www.gvu.gatech.edu/~jarek
Jarek Rossignac
What is the Boolean product?
The dot product of two Boolean vectors is the disjunctive form
[ ai ]k [ bi ]k = a1b1 a2b2 …
akbk
The Boolean product of two binary matrices is
[ aij ]mk[ bij ]kn = [ ai* b*j ]mn
![Page 24: Lecture 08a: MATRICES Sec 2.7](https://reader036.fdocuments.us/reader036/viewer/2022062521/56814c7e550346895db99ba8/html5/thumbnails/24.jpg)
24Georgia Tech, IIC, GVU, 2006MAGIC MAGIC LabLab
http://www.gvu.gatech.edu/~jarek
Jarek Rossignac
What is the Boolean product?
The dot product of two Boolean vectors is the disjunctive form
[ ai ]k [ bi ]k = a1b1 a2b2 …
akbk
The Boolean product of two binary matrices is
[ aij ]mk[ bij ]kn = [ ai* b*j ]mn
![Page 25: Lecture 08a: MATRICES Sec 2.7](https://reader036.fdocuments.us/reader036/viewer/2022062521/56814c7e550346895db99ba8/html5/thumbnails/25.jpg)
25Georgia Tech, IIC, GVU, 2006MAGIC MAGIC LabLab
http://www.gvu.gatech.edu/~jarek
Jarek Rossignac
What is the Boolean power?
The rth Boolean power , denoted A[r], of a square binary matrix A is
A[r] = AA … A (Boolean product of r terms)
with A[0] = I
![Page 26: Lecture 08a: MATRICES Sec 2.7](https://reader036.fdocuments.us/reader036/viewer/2022062521/56814c7e550346895db99ba8/html5/thumbnails/26.jpg)
26Georgia Tech, IIC, GVU, 2006MAGIC MAGIC LabLab
http://www.gvu.gatech.edu/~jarek
Jarek Rossignac
Assigned Reading
• 2.7
![Page 27: Lecture 08a: MATRICES Sec 2.7](https://reader036.fdocuments.us/reader036/viewer/2022062521/56814c7e550346895db99ba8/html5/thumbnails/27.jpg)
27Georgia Tech, IIC, GVU, 2006MAGIC MAGIC LabLab
http://www.gvu.gatech.edu/~jarek
Jarek Rossignac
Assigned Exercises for Quiz
• Page 204-205: 4.a, 13, 19• Changes of coordinate system• Assume that you have a series of m
transformations each represented in homogeneous form by a 4x4 matrix and v vertices, which you want to transform by each matrix in the series. Is it cheaper to first compute the result of multiplying the series into a single matrix and then use it to transform all the vertices, or is it cheaper to multiply each vertex by the each matrix? Does the answer depend on the values of m and v? If so, how?
![Page 28: Lecture 08a: MATRICES Sec 2.7](https://reader036.fdocuments.us/reader036/viewer/2022062521/56814c7e550346895db99ba8/html5/thumbnails/28.jpg)
28Georgia Tech, IIC, GVU, 2006MAGIC MAGIC LabLab
http://www.gvu.gatech.edu/~jarek
Jarek Rossignac
Assigned Project