Lecture 6: More Matlab Functions, Transformations: Professor Erik Cheever Course Web Page
Lecture 6: More Matlab Functions, Transformations: Professor Erik Cheever Course Web Page
An example:
Suppose we want to find the perimeter of a shape
defined by a “patch.”
-1
>> %Difference between x values
>> xd=diff(x) -2
xd = 1 2 -1 -3
-3 -2 -1 0 1 2 3
>> xd=diff(x1)
xd = 1 2 -1 -2
Finding perimeter (2) d x1 x2
2
y1 y2
2
function p = perim(xvals,yvals)
>> q=perim(x,y)
q = 6.8284
x cos φ , y sin φ
x' cos θ φ , y' sin θ φ
Trig identities :
cos θ φ cos φ cos θ sin φ sin θ
sin θ φ cos φ sin θ sin φ cos θ
cos θ sin θ
rotation matrix=R
sin θ cos θ
Translation of a point (3x3)
x' x tx , y' y ty
x' 1 0 tx x
y' 0 1 ty y
1 0 0 1 1
1 0 tx
0 1 ty translation matrix=M
0 0 1
If the points define a shape, we can rotate and translate that shape with a
single matrix multiplication.
… MatLab demo…
Other transformations…
(that we won’t be using)
Scaling
Shearing
Reflection