lecture 08a: matrices sec 2.7

Post on 19-Mar-2016

40 Views

Category:

Documents

3 Downloads

Preview:

Click to see full reader

DESCRIPTION

Lecture 08a: MATRICES Sec 2.7. CS1050: Understanding and Constructing Proofs. Spring 2006. Jarek Rossignac. Lecture Objectives. Understand vectors, matrices, their products and properties. Illustrate these on linear transformations. What do coordinates mean?. - PowerPoint PPT Presentation

TRANSCRIPT

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

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

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

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

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 )

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 )

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

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

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)

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

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

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

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)

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 =

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

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

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

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

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)

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

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.

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

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

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

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

26Georgia Tech, IIC, GVU, 2006MAGIC MAGIC LabLab

http://www.gvu.gatech.edu/~jarek

Jarek Rossignac

Assigned Reading

• 2.7

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?

28Georgia Tech, IIC, GVU, 2006MAGIC MAGIC LabLab

http://www.gvu.gatech.edu/~jarek

Jarek Rossignac

Assigned Project

top related