Professional Documents
Culture Documents
Todays goals:
Learn enough matlab to get started.
Review some basics of Linear Algebra
Essential for geometry of points and lines.
But also, all math is linear algebra.
(ok slight exaggeration).
Many slides today adapted from Octavia
Camps, Penn State.
Starting Matlab
For PCs, Matlab should be a program.
For Suns:
Numerical
Matlab 6.1
Help
help
help command
Eg., help plus
Help on toolbar
demo
Tutorial:
http://amath.colorado.edu/scico/tutorials/
matlab/
Matlab interpreter
Many common functions: see help ops
Vectors
v ( x1 , x2 , , xn )
Ordered set of
numbers: (1,2,3,4)
v
Example: (x,y,z)
coordinates of pt in
If
space.
i 1
v 1, v is a unit vector
Vector Addition
v w ( x1 , x2 ) ( y1 , y2 ) ( x1 y1 , x2 y2 )
V+w
w
Scalar Product
av a ( x1 , x2 ) (ax1 , ax2 )
av
v
Operations on vectors
sum
max, min, mean, sort,
Pointwise: .^
v.w ( x1 , x2 ).( y1 , y2 ) x1 y1 x2 . y2
Matrices
Anm
a11
a
21
a31
an1
a12
a1m
Sum:
a22 a2 m
a32 a3m
an 2 anm
Matrices
Product:
Cn p Anm Bm p
m
Identity Matrix:
0 0 1
IA AI A
Matrices
Transpose:
Cmn A
nm
cij a ji
If
A A
T
( A B) A B
T
( AB)T B T AT
A is symmetric
Matrices
Determinant:
A must be square
a11
det
a21
a12
a11
a22
a21
a11
det a21
a31
a12
a22
a32
a12
a11a22 a21a12
a22
a13
a22
a23 a11
a32
a33
a23
a21
a12
a33
a31
a23
a21
a13
a33
a31
a22
a32
Matrices
Inverse:
Ann A
a11
a
21
A must be square
1
n n
a12
a22
A
1
nn
Ann I
a11a22 a21a12
a22
a
21
a12
a11
Euclidean transformations
2D Translation
P
t
P
2D Translation Equation
ty
P ( x, y )
t (t x , t y )
y
x
tx
P ' ( x t x , y t y ) Pt
y
x
tx
P ( x, y )
t (t x , t y )
t
x tx 1 0 tx
P'
y ty 0 1 ty
x
y
1
Scaling
P
Scaling Equation
P
s.y
P
P ( x, y )
P ' ( sx, sy )
P' s P
y
x
s.x
sx s 0 x
P'
sy 0 s y
P' S P
Rotation
P
P
Rotation Equations
Counter-clockwise rotation by an angle
y
X
x' cos
y ' sin
P' R.P
sin x
cos y
Degrees of Freedom
x' cos
y ' sin
sin x
cos y
R is 2x2
4 elements
R RT RT R I
det(R ) 1
Stretching Equation
P ( x, y )
P ' ( s x x, s y y )
Sy.y
sx x sx
P'
s
y
0
y
P
y
x
0
s y
S
Sx.x
P' S P
x
y
s
y
0
y
0
s y
x
y
sx
sy sy
0 x
y
1
Linear Transformation
a b
P'
c
d
x
y
sin
cos
cos
sin
sin
sy
cos
SVD
sx
0
cos
sin
sx
s
y
0
sy
sin
cos
0 sin
cos
1
cos
sin
x
y
cos x
sin y
Affine Transformation
a b tx
P'
c d ty
x
y
1
Files
Functions
Format: function o = test(x,y)
Name function and file the same.
Only first function in file is visible
outside the file.
Images
Debugging
Add print statements to function by
leaving off ;
keyboard
debug and breakpoint
Conclusions
Quick tour of matlab, you should teach
yourself the rest. Well give hints in
problem sets.
Linear algebra allows geometric
manipulation of points.
Learn to love SVD.