-
Notifications
You must be signed in to change notification settings - Fork 1
/
test_computeBisectionCost.m
84 lines (71 loc) · 2.43 KB
/
test_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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
clc
clear bisection_t
bisection_t(1).s = 0.1;
bisection_t(2).s = 10;
i = 1;
%%
i
[bisection_t] = computeBisectionCost_t(correspondences, bisection_t);
i = i + 1;
% if bisection_t(1).cost > bisection_t(2).cost
% bisection_t(1).s = bisection_t(3).s;
% bisection_t(1).cost = bisection_t(3).cost;
% else
% bisection_t(2).s = bisection_t(3).s;
% bisection_t(2).cost = bisection_t(3).cost;
% end
% disp("s")
% bisection_t.s
% disp("cost")
% bisection_t.cost
function bisection_t = computeBisectionCost_t(correspondences, bisection_t)
gt_T.t = [-0.12423
-2.5415
0.27721];
gt_T.R = [-0.66012 -0.74424 0.10168
0.42388 -0.48083 -0.76755
0.62013 -0.46358 0.63288];
% centroid = computeCentroid(correspondences);
centroid = Point();
if ~isfield(bisection_t(1), 'cost') || isempty(bisection_t(1).cost)
bisection_t(1).cost = sum(correspondences.signed_cost(...
SimPose(gt_T.t, gt_T.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(gt_T.t, gt_T.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
disp("------------------- s -------------------")
bisection_t.s
disp("------------------- cost -------------------")
bisection_t.cost
disp("------------------- new s and cost -------------------")
s = (bisection_t(1).s + bisection_t(2).s)/ 2
cost = sum(correspondences.signed_cost(...
SimPose(gt_T.t, gt_T.R, s), centroid))
disp("======================================================")
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