Linear Algebra Review - University Of Maryland · 2015. 9. 10. · Linear Algebra Review. 09-Sep-15...
Transcript of Linear Algebra Review - University Of Maryland · 2015. 9. 10. · Linear Algebra Review. 09-Sep-15...
Linear Algebra Review
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
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
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
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
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
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
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
09-Sep-15 Octavia I. Camps 9
Vector Addition
),(),(),( 22112121 yxyxyyxx wv
vw
V+w
09-Sep-15 Octavia I. Camps 10
Vector Subtraction
),(),(),( 22112121 yxyxyyxx wv
vw
V-w
09-Sep-15 Octavia I. Camps 11
Scalar Product
),(),( 2121 axaxxxaa v
v
av
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.
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
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:
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
2D Geometrical Transformations
09-Sep-15 Octavia I. Camps 17
2D Translation
t
P
P’
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
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
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!
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
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
09-Sep-15 Octavia I. Camps 23
Scaling
P
P’
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 '
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
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
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
09-Sep-15 Octavia I. Camps 28
Rotation
P
P’
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'
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
'
'
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 …
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
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
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