Line | |
---|
1 | % By Philip Torr 2002
|
---|
2 | % copyright Microsoft Corp.
|
---|
3 | %makes a super quick fit (Torr trick of the trade...)
|
---|
4 | %example given two points we can determine a quick fit to a line as
|
---|
5 |
|
---|
6 |
|
---|
7 | % det [i j k ]
|
---|
8 | % [x y m3]
|
---|
9 | % [x' y' m3]
|
---|
10 | %
|
---|
11 | % where the coefficients of i,j,k are the coefficients of the line
|
---|
12 |
|
---|
13 | %this result generalizes to any dimension allowing for quick fitting of minimal sets without SVD.
|
---|
14 |
|
---|
15 | %for Matlab there is no gain over SVD, but there might be for C++
|
---|
16 |
|
---|
17 |
|
---|
18 | function result = torr_quick_fit(M)
|
---|
19 |
|
---|
20 |
|
---|
21 | nc = length(M);
|
---|
22 | normM = norm(M);
|
---|
23 |
|
---|
24 | % if (nr ~= nc-1)
|
---|
25 | % error('wrong matrix size in torr_quick_fit');
|
---|
26 | % end
|
---|
27 |
|
---|
28 | for i = 1:nc
|
---|
29 | A = M(:, [1:i-1 i+1:nc])/normM;
|
---|
30 | result(i) = (-1)^(i+1) * det(A);
|
---|
31 | end
|
---|
32 |
|
---|
33 |
|
---|
34 | result = result'/norm(result);
|
---|
35 |
|
---|
36 |
|
---|
37 |
|
---|
Note: See
TracBrowser
for help on using the repository browser.