linear algebra review - university of maryland · 2015. 9. 10. · linear algebra review. 09-sep-15...

34
Linear Algebra Review

Upload: others

Post on 14-Sep-2020

1 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Linear Algebra Review - University Of Maryland · 2015. 9. 10. · Linear Algebra Review. 09-Sep-15 Octavia I. Camps 2 Why do we need Linear Algebra? • We will associate coordinates

Linear Algebra Review

Page 2: Linear Algebra Review - University Of Maryland · 2015. 9. 10. · Linear Algebra Review. 09-Sep-15 Octavia I. Camps 2 Why do we need Linear Algebra? • We will associate coordinates

09-Sep-15 Octavia I. Camps 2

Why do we need Linear Algebra?

• We will associate coordinates to– 3D points in the scene– 2D points in the CCD array– 2D points in the image

• Coordinates will be used to– Perform geometrical transformations– Associate 3D with 2D points

• Images are matrices of numbers– We will find properties of these numbers

Page 3: Linear Algebra Review - University Of Maryland · 2015. 9. 10. · Linear Algebra Review. 09-Sep-15 Octavia I. Camps 2 Why do we need Linear Algebra? • We will associate coordinates

09-Sep-15 Octavia I. Camps 3

Matrices

nmnn

m

m

m

mn

aaa

aaa

aaa

aaa

A

21

33231

22221

11211

mnmnmn BAC Sum:

ijijij bac

64

78

51

26

13

52Example:

A and B must have the same dimensions

Page 4: Linear Algebra Review - University Of Maryland · 2015. 9. 10. · Linear Algebra Review. 09-Sep-15 Octavia I. Camps 2 Why do we need Linear Algebra? • We will associate coordinates

09-Sep-15 Octavia I. Camps 4

Matrices

pmmnpn BAC Product:

m

k

kjikij bac1

1119

2917

51

26.

13

52

Examples:

1017

3218

13

52.

51

26

nnnnnnnn ABBA

A and B must have compatible dimensions

Page 5: Linear Algebra Review - University Of Maryland · 2015. 9. 10. · Linear Algebra Review. 09-Sep-15 Octavia I. Camps 2 Why do we need Linear Algebra? • We will associate coordinates

09-Sep-15 Octavia I. Camps 5

Matrices

mnT

nm AC

Transpose:

jiij ac TTT ABAB )(

TTT BABA )(

If AAT A is symmetric

Examples:

52

16

51

26T

852

316

83

51

26T

Page 6: Linear Algebra Review - University Of Maryland · 2015. 9. 10. · Linear Algebra Review. 09-Sep-15 Octavia I. Camps 2 Why do we need Linear Algebra? • We will associate coordinates

09-Sep-15 Octavia I. Camps 6

Matrices

Determinant:

1315213

52det

Example:

A must be square

3231

2221

13

3331

2321

12

3332

2322

11

333231

232221

131211

detaa

aaa

aa

aaa

aa

aaa

aaa

aaa

aaa

12212211

2221

1211

2221

1211det aaaa

aa

aa

aa

aa

Page 7: Linear Algebra Review - University Of Maryland · 2015. 9. 10. · Linear Algebra Review. 09-Sep-15 Octavia I. Camps 2 Why do we need Linear Algebra? • We will associate coordinates

09-Sep-15 Octavia I. Camps 7

Matrices

IAAAA nnnnnnnn

11

Inverse: A must be square

1121

1222

12212211

1

2221

1211 1

aa

aa

aaaaaa

aa

Example:

61

25

28

1

51

261

10

01

280

028

28

1

51

26.

61

25

28

1

51

26.

51

261

Page 8: Linear Algebra Review - University Of Maryland · 2015. 9. 10. · Linear Algebra Review. 09-Sep-15 Octavia I. Camps 2 Why do we need Linear Algebra? • We will associate coordinates

09-Sep-15 Octavia I. Camps 8

2D Vector),( 21 xxv

P

x1

x2

v

Magnitude: 2

2

2

1|||| xx v

Orientation:

1

21tanx

x

||||,

||||||||

21

vvv

v xxIs a unit vector

If 1|||| v , v Is a UNIT vector

Page 9: Linear Algebra Review - University Of Maryland · 2015. 9. 10. · Linear Algebra Review. 09-Sep-15 Octavia I. Camps 2 Why do we need Linear Algebra? • We will associate coordinates

09-Sep-15 Octavia I. Camps 9

Vector Addition

),(),(),( 22112121 yxyxyyxx wv

vw

V+w

Page 10: Linear Algebra Review - University Of Maryland · 2015. 9. 10. · Linear Algebra Review. 09-Sep-15 Octavia I. Camps 2 Why do we need Linear Algebra? • We will associate coordinates

09-Sep-15 Octavia I. Camps 10

Vector Subtraction

),(),(),( 22112121 yxyxyyxx wv

vw

V-w

Page 11: Linear Algebra Review - University Of Maryland · 2015. 9. 10. · Linear Algebra Review. 09-Sep-15 Octavia I. Camps 2 Why do we need Linear Algebra? • We will associate coordinates

09-Sep-15 Octavia I. Camps 11

Scalar Product

),(),( 2121 axaxxxaa v

v

av

Page 12: Linear Algebra Review - University Of Maryland · 2015. 9. 10. · Linear Algebra Review. 09-Sep-15 Octavia I. Camps 2 Why do we need Linear Algebra? • We will associate coordinates

09-Sep-15 Octavia I. Camps 12

Inner (dot) Product

v

w

22112121 .),).(,(. yxyxyyxxwv

The inner product is a SCALAR!

cos||||||||),).(,(. 2121 wvyyxxwv

wvwv 0.

Page 13: Linear Algebra Review - University Of Maryland · 2015. 9. 10. · Linear Algebra Review. 09-Sep-15 Octavia I. Camps 2 Why do we need Linear Algebra? • We will associate coordinates

09-Sep-15 Octavia I. Camps 13

Orthonormal Basis

),( 21 xxv

1||||

1||||

j

i

jiv .. 21 xx

P

x1

x2

v

ij )1,0(

)0,1(

j

i0 ji

12121 0.1.)...(. xxxxx ijiiv

22121 1.0.)...(. xxxxx jjijv

Page 14: Linear Algebra Review - University Of Maryland · 2015. 9. 10. · Linear Algebra Review. 09-Sep-15 Octavia I. Camps 2 Why do we need Linear Algebra? • We will associate coordinates

09-Sep-15 Octavia I. Camps 14

Vector (cross) Product

wvu

The cross product is a VECTOR!

w

v

u

0)(

0)(

wwvwuwu

vwvvuvuOrientation:

sin|||||||||.|| ||u|| wvwv Magnitude:

Page 15: Linear Algebra Review - University Of Maryland · 2015. 9. 10. · Linear Algebra Review. 09-Sep-15 Octavia I. Camps 2 Why do we need Linear Algebra? • We will associate coordinates

09-Sep-15 Octavia I. Camps 15

Vector Product Computation

),,(),,( 321321 yyyxxx wvu

1||||

1||||

1||||

k

j

i

kji

kji

u

)()()( 122131132332

321

321

yxyxyxyxyxyx

yyy

xxx

)1,0,0(

)0,1,0(

)0,0,1(

k

j

i

0,0,0 kjkiji

w

v

u

Page 16: Linear Algebra Review - University Of Maryland · 2015. 9. 10. · Linear Algebra Review. 09-Sep-15 Octavia I. Camps 2 Why do we need Linear Algebra? • We will associate coordinates

2D Geometrical Transformations

Page 17: Linear Algebra Review - University Of Maryland · 2015. 9. 10. · Linear Algebra Review. 09-Sep-15 Octavia I. Camps 2 Why do we need Linear Algebra? • We will associate coordinates

09-Sep-15 Octavia I. Camps 17

2D Translation

t

P

P’

Page 18: Linear Algebra Review - University Of Maryland · 2015. 9. 10. · Linear Algebra Review. 09-Sep-15 Octavia I. Camps 2 Why do we need Linear Algebra? • We will associate coordinates

09-Sep-15 Octavia I. Camps 18

2D Translation Equation

P

x

y

tx

ty

P’t

tPP ),(' yx tytx

),(

),(

yx tt

yx

t

P

Page 19: Linear Algebra Review - University Of Maryland · 2015. 9. 10. · Linear Algebra Review. 09-Sep-15 Octavia I. Camps 2 Why do we need Linear Algebra? • We will associate coordinates

09-Sep-15 Octavia I. Camps 19

2D Translation using Matrices

P

x

y

tx

ty

P’t

),(

),(

yx tt

yx

t

P

11

0

0

1' y

x

t

t

ty

tx

y

x

y

xP

t P

Page 20: Linear Algebra Review - University Of Maryland · 2015. 9. 10. · Linear Algebra Review. 09-Sep-15 Octavia I. Camps 2 Why do we need Linear Algebra? • We will associate coordinates

09-Sep-15 Octavia I. Camps 20

Homogeneous Coordinates

• Multiply the coordinates by a non-zero scalar and add an extra coordinate equal to that scalar. For example,

0 ),,,(),,(

0 ),,(),(

wwwzwywxzyx

zzzyzxyx

• NOTE: If the scalar is 1, there is no need for the multiplication!

Page 21: Linear Algebra Review - University Of Maryland · 2015. 9. 10. · Linear Algebra Review. 09-Sep-15 Octavia I. Camps 2 Why do we need Linear Algebra? • We will associate coordinates

09-Sep-15 Octavia I. Camps 21

Back to Cartesian Coordinates:

• Divide by the last coordinate and eliminate it. For example,

)/,/,/(0 ),,,(

)/,/(0 ),,(

wzwywxwwzyx

zyzxzzyx

Page 22: Linear Algebra Review - University Of Maryland · 2015. 9. 10. · Linear Algebra Review. 09-Sep-15 Octavia I. Camps 2 Why do we need Linear Algebra? • We will associate coordinates

09-Sep-15 Octavia I. Camps 22

2D Translation using Homogeneous Coordinates

P

x

y

tx

ty

P’t

1100

10

01

1

' y

x

t

t

ty

tx

y

x

y

x

P

)1,,(),(

)1,,(),(

yxyx tttt

yxyx

t

P t

P

PTP 'T

Page 23: Linear Algebra Review - University Of Maryland · 2015. 9. 10. · Linear Algebra Review. 09-Sep-15 Octavia I. Camps 2 Why do we need Linear Algebra? • We will associate coordinates

09-Sep-15 Octavia I. Camps 23

Scaling

P

P’

Page 24: Linear Algebra Review - University Of Maryland · 2015. 9. 10. · Linear Algebra Review. 09-Sep-15 Octavia I. Camps 2 Why do we need Linear Algebra? • We will associate coordinates

09-Sep-15 Octavia I. Camps 24

Scaling Equation

P

x

y

Sx.x

P’Sy.y

1100

00

00

1

' y

x

s

s

ys

xs

y

x

y

x

P

)1,,(),('

)1,,(),(

ysxsysxs

yxyx

yxyx

P

P

SPSP '

Page 25: Linear Algebra Review - University Of Maryland · 2015. 9. 10. · Linear Algebra Review. 09-Sep-15 Octavia I. Camps 2 Why do we need Linear Algebra? • We will associate coordinates

09-Sep-15 Octavia I. Camps 25

Scaling & Translating

P

P’=S.P

P’’=T.P’

P’’=T.P’=T.(S.P)=(T.S).P

S

T

Page 26: Linear Algebra Review - University Of Maryland · 2015. 9. 10. · Linear Algebra Review. 09-Sep-15 Octavia I. Camps 2 Why do we need Linear Algebra? • We will associate coordinates

09-Sep-15 Octavia I. Camps 26

Scaling & TranslatingP’’=T.P’=T.(S.P)=(T.S).P

11100

0

0

1100

00

00

100

10

01

''

yy

xx

yy

xx

y

x

y

x

tys

txs

y

x

ts

ts

y

x

s

s

t

t

PSTP

Page 27: Linear Algebra Review - University Of Maryland · 2015. 9. 10. · Linear Algebra Review. 09-Sep-15 Octavia I. Camps 2 Why do we need Linear Algebra? • We will associate coordinates

09-Sep-15 Octavia I. Camps 27

Translating & Scaling Scaling & Translating

P’’=S.P’=S.(T.P)=(S.T).P

11100

0

0

1100

10

01

100

00

00

''

yyy

xxx

yyy

xxx

y

x

y

x

tsys

tsxs

y

x

tss

tss

y

x

t

t

s

s

PTSP

Page 28: Linear Algebra Review - University Of Maryland · 2015. 9. 10. · Linear Algebra Review. 09-Sep-15 Octavia I. Camps 2 Why do we need Linear Algebra? • We will associate coordinates

09-Sep-15 Octavia I. Camps 28

Rotation

P

P’

Page 29: Linear Algebra Review - University Of Maryland · 2015. 9. 10. · Linear Algebra Review. 09-Sep-15 Octavia I. Camps 2 Why do we need Linear Algebra? • We will associate coordinates

09-Sep-15 Octavia I. Camps 29

Rotation Equations

Counter-clockwise rotation by an angle

y

x

y

x

cossin

sincos

'

'

P

x

Y’P’

X’

y R.PP'

Page 30: Linear Algebra Review - University Of Maryland · 2015. 9. 10. · Linear Algebra Review. 09-Sep-15 Octavia I. Camps 2 Why do we need Linear Algebra? • We will associate coordinates

09-Sep-15 Octavia I. Camps 30

Degrees of Freedom

R is 2x2 4 elements

BUT! There is only 1 degree of freedom:

1)det(

R

IRRRR TT

The 4 elements must satisfy the following constraints:

y

x

y

x

cossin

sincos

'

'

Page 31: Linear Algebra Review - University Of Maryland · 2015. 9. 10. · Linear Algebra Review. 09-Sep-15 Octavia I. Camps 2 Why do we need Linear Algebra? • We will associate coordinates

09-Sep-15 Octavia I. Camps 31

Scaling, Translating & Rotating

Order matters!

P’ = S.PP’’=T.P’=(T.S).PP’’’=R.P”=R.(T.S).P=(R.T.S).P

R.T.S R.S.T T.S.R …

Page 32: Linear Algebra Review - University Of Maryland · 2015. 9. 10. · Linear Algebra Review. 09-Sep-15 Octavia I. Camps 2 Why do we need Linear Algebra? • We will associate coordinates

09-Sep-15 Octavia I. Camps 32

3D Rotation of PointsRotation around the coordinate axes, counter-clockwise:

100

0cossin

0sincos

)(

cos0sin

010

sin0cos

)(

cossin0

sincos0

001

)(

z

y

x

R

R

R

P

x

Y’P’

X’

y

z

Page 33: Linear Algebra Review - University Of Maryland · 2015. 9. 10. · Linear Algebra Review. 09-Sep-15 Octavia I. Camps 2 Why do we need Linear Algebra? • We will associate coordinates

09-Sep-15 Octavia I. Camps 33

3D Rotation (axis & angle)

0

0

0

sin)cos1(cos

angle ,

12

13

23

2

33231

32

2

221

3121

2

1

321

nn

nn

nn

nnnnn

nnnnn

nnnnn

nnnT

IIR

n

Page 34: Linear Algebra Review - University Of Maryland · 2015. 9. 10. · Linear Algebra Review. 09-Sep-15 Octavia I. Camps 2 Why do we need Linear Algebra? • We will associate coordinates

09-Sep-15 Octavia I. Camps 34

3D Translation of Points

Translate by a vector t=(tx,ty,tx)T:

1000

100

010

001

z

y

x

t

t

t

T

PxY’

P’

x’

yz

z’

t