Linear Algebra Review
Dec 22, 2015
04/19/23 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
04/19/23 Octavia I. Camps 3
Matrices
nmnn
m
m
m
mn
aaa
aaa
aaa
aaa
A
21
33231
22221
11211
mnmnmn BAC Sum:Sum:
ijijij bac
64
78
51
26
13
52Example:Example:
A and B must have the A and B must have the same dimensionssame dimensions
04/19/23 Octavia I. Camps 4
Matrices
pmmnpn BAC Product:Product:
m
kkjikij bac
1
1119
2917
51
26.
13
52
Examples:Examples:
1017
3218
13
52.
51
26
nnnnnnnn ABBA
A and B must have A and B must have compatible dimensionscompatible dimensions
04/19/23 Octavia I. Camps 5
Matrices
mnT
nm AC Transpose:Transpose:
jiij ac TTT ABAB )(
TTT BABA )(
If If AAT A is symmetricA is symmetric
Examples:Examples:
52
16
51
26T
852
316
83
51
26T
04/19/23 Octavia I. Camps 6
Matrices
Determinant:Determinant:
1315213
52det
Example:Example:
A must be squareA must be square
3231
222113
3331
232112
3332
232211
333231
232221
131211
detaa
aaa
aa
aaa
aa
aaa
aaa
aaa
aaa
122122112221
1211
2221
1211det aaaaaa
aa
aa
aa
04/19/23 Octavia I. Camps 7
Matrices
IAAAA nnnnnnnn
11
Inverse:Inverse: A must be squareA must be square
1121
1222
12212211
1
2221
1211 1
aa
aa
aaaaaa
aa
Example:Example:
61
25
28
1
51
261
10
01
280
028
28
1
51
26.
61
25
28
1
51
26.
51
261
04/19/23 Octavia I. Camps 8
2D Vector),( 21 xxv
PP
x1x1
x2x2
vv
Magnitude:Magnitude: 22
21|||| xx v
Orientation:Orientation:
1
21tanx
x
||||,
||||||||21
vvv
v xxIs a unit vectorIs a unit vector
If If 1|||| v , , v Is a UNIT vectorIs a UNIT vector
04/19/23 Octavia I. Camps 12
Inner (dot) Product
vv
ww
22112121 .),).(,(. yxyxyyxxwv
The inner product is a The inner product is a SCALAR!SCALAR!
cos||||||||),).(,(. 2121 wvyyxxwv
wvwv 0.
04/19/23 Octavia I. Camps 13
Orthonormal Basis
),( 21 xxv
1||||
1||||
j
i
jiv .. 21 xx
PP
x1x1
x2x2
vv
iijj )1,0(
)0,1(
j
i 0ji
12121 0.1.)...(. xxxxx ijiiv
22121 1.0.)...(. xxxxx jjijv
04/19/23 Octavia I. Camps 14
Vector (cross) Product
wvu
The cross product is a The cross product is a VECTOR!VECTOR!
ww
vv
uu
0)(
0)(
wwvwuwu
vwvvuvuOrientation:Orientation:
sin|||||||||.|| ||u|| wvwv Magnitude:Magnitude:
04/19/23 Octavia I. Camps 15
Vector Product Computation
),,(),,( 321321 yyyxxx wvu
kji
kji
u
)()()( 122131132332
321
321
yxyxyxyxyxyx
yyy
xxx
ww
vv
uu
i=(1,0,0)i=(1,0,0)j=(0,1,0)j=(0,1,0)k=(0,0,1)k=(0,0,1) 1k
1j
1i
i.j=0 , i.k=0 , i.j=0 , i.k=0 , j.k=0j.k=0
04/19/23 Octavia I. Camps 18
2D Translation Equation
PP
xx
yy
ttxx
ttyy
P’P’tt
tPP ),(' yx tytx
),(
),(
yx tt
yx
t
P
04/19/23 Octavia I. Camps 19
2D Translation using Matrices
PP
xx
yy
ttxx
ttyy
P’P’tt
),(
),(
yx tt
yx
t
P
1
1
0
0
1' y
x
t
t
ty
tx
y
x
y
xP
tt PP
04/19/23 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!
04/19/23 Octavia I. Camps 21
Back to Cartesian Coordinates:
• Divide by the last coordinate and eliminate it. For example,
)/,/,/(0 ),,,(
)/,/(0 ),,(
wzwywxwwzyx
zyzxzzyx
04/19/23 Octavia I. Camps 22
2D Translation using Homogeneous Coordinates
PP
xx
yy
ttxx
ttyy
P’P’tt
1100
10
01
1
' y
x
t
t
ty
tx
y
x
y
x
P
)1,,(),(
)1,,(),(
yxyx tttt
yxyx
t
P tt
PP
PTP ' T
04/19/23 Octavia I. Camps 24
Scaling Equation
PP
xx
yy
SSxx.x.x
P’P’SSyy.y.y
1100
00
00
1
' y
x
s
s
ys
xs
y
x
y
x
P
)1,,(),('
)1,,(),(
ysxsysxs
yxyx
yxyx
P
P
SPSP '
04/19/23 Octavia I. Camps 25
Scaling & Translating
PP
P’=S.PP’=S.P
P’’=T.P’P’’=T.P’
P’’=T.P’=T.(S.P)=(T.S).PP’’=T.P’=T.(S.P)=(T.S).P
SS
TT
04/19/23 Octavia I. Camps 26
Scaling & TranslatingP’’=T.P’=T.(S.P)=(T.S).PP’’=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
04/19/23 Octavia I. Camps 27
Translating & Scaling Scaling & Translating
P’’=S.P’=S.(T.P)=(S.T).PP’’=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
04/19/23 Octavia I. Camps 29
Rotation Equations
Counter-clockwise rotation by an angle Counter-clockwise rotation by an angle
y
x
y
x
cossin
sincos
'
'
PP
xx
Y’Y’PP’’
X’X’
yy R.PP'
04/19/23 Octavia I. Camps 30
Degrees of Freedom
R is 2x2 R is 2x2 4 elements4 elements
BUT! There is only 1 degree of freedom: BUT! There is only 1 degree of freedom:
1)det(
R
IRRRR TT
The 4 elements must satisfy the following constraints:The 4 elements must satisfy the following constraints:
y
x
y
x
cossin
sincos
'
'
04/19/23 Octavia I. Camps 31
Scaling, Translating & Rotating
Order matters!Order matters!
P’ = S.PP’ = S.PP’’=T.P’=(T.S).PP’’=T.P’=(T.S).PP’’’=R.P”=R.(T.S).P=(R.T.S).P P’’’=R.P”=R.(T.S).P=(R.T.S).P
R.T.S R.T.S R.S.T R.S.T T.S.R … T.S.R …
04/19/23 Octavia I. Camps 32
3D Rotation of PointsRotation around the coordinate axes, Rotation around the coordinate axes, counter-clockwisecounter-clockwise::
100
0cossin
0sincos
)(
cos0sin
010
sin0cos
)(
cossin0
sincos0
001
)(
z
y
x
R
R
R
PP
xx
Y’Y’PP’’
X’X’
yy
zz
04/19/23 Octavia I. Camps 33
3D Rotation (axis & angle)
0
0
0
sin)cos1(cos
angle ,
12
13
23
233231
322
221
31212
1
321
nn
nn
nn
nnnnn
nnnnn
nnnnn
nnn T
IIR
n