-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcomputeBisectionCost.m
51 lines (40 loc) · 1.58 KB
/
computeBisectionCost.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
function bisection_t = computeBisectionCost(correspondences, bisection_t, centroid)
if ~exist('centroid', 'var') || isempty(centroid)
centroid = Point();
end
if ~isfield(bisection_t(1), 'cost') || isempty(bisection_t(1).cost)
bisection_t(1).cost = sum(correspondences.signed_cost(...
SimPose(bisection_t(1).t, bisection_t(1).R, bisection_t(1).s), centroid));
end
if ~isfield(bisection_t(2), 'cost') || isempty(bisection_t(2).cost)
bisection_t(2).cost = sum(correspondences.signed_cost(...
SimPose(bisection_t(2).t, bisection_t(2).R, bisection_t(2).s), centroid));
end
if size(bisection_t, 2) == 2
if bisection_t(1).cost < bisection_t(2).cost
bisection_t(3).s = bisection_t(1).s;
bisection_t(3).cost = bisection_t(1).cost;
else
bisection_t(3).s = bisection_t(2).s;
bisection_t(3).cost = bisection_t(2).cost;
end
end
s = (bisection_t(1).s + bisection_t(2).s)/ 2;
cost = norm(correspondences.signed_cost(...
SimPose(gt_T.t, gt_T.R, s), centroid));
if bisection_t(1).cost * cost < 0
% old data
bisection_t(3).s = bisection_t(2).s;
bisection_t(3).cost = bisection_t(2).cost;
% new data
bisection_t(2).s = s;
bisection_t(2).cost = cost;
else
% old data
bisection_t(3).s = bisection_t(1).s;
bisection_t(3).cost = bisection_t(1).cost;
% new data
bisection_t(1).s = s;
bisection_t(1).cost = cost;
end
end