-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathparameters.cpp
64 lines (51 loc) · 1.88 KB
/
parameters.cpp
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
#include <parameters.hpp>
//----------------------------------------------------------------------
//
// utility functions
//
//----------------------------------------------------------------------
float makeRectangularXYc(float left, float right) {
return (left + right) * 0.5f;
}
float makeAnnularRo(float right_x, float right_y, float left_x, float left_y) {
return 0.5f * std::min(abs(right_x - left_x), abs(right_y - left_y));
}
float makeAnnularRi(float right_x, float right_y, float left_x, float left_y,
float ri_by_ro) {
return ri_by_ro * makeAnnularRo(right_x, right_y, left_x, left_y);
}
float makeAnnularXc(float right_x, float right_y, float left_x, float left_y) {
return (right_x > left_x
? (float)left_x + makeAnnularRo(right_x, right_y, left_x, left_y)
: (float)left_x -
makeAnnularRo(right_x, right_y, left_x, left_y));
}
float makeAnnularYc(float right_x, float right_y, float left_x, float left_y) {
return (right_y > left_y
? (float)left_y + makeAnnularRo(right_x, right_y, left_x, left_y)
: (float)left_y -
makeAnnularRo(right_x, right_y, left_x, left_y));
}
float makeblobXc(v_points contour_in) {
float xc = 0;
for (int i = 0; i < (int)contour_in.size(); ++i) {
xc += contour_in[i].first;
}
return xc / (float)contour_in.size();
}
float makeblobYc(v_points contour_in) {
float yc = 0;
for (int i = 0; i < (int)contour_in.size(); ++i) {
yc += contour_in[i].second;
}
return yc / (float)contour_in.size();
}
float best_rotation_UVUxUyVxVy(float *model_parameters) {
return atan2((model_parameters[4] - model_parameters[3]),
(model_parameters[2] + model_parameters[5] + 2.f));
}
void copy_model_parameters(float *source, float *destination, int n_p) {
for (int p = 0; p < n_p; ++p) {
destination[p] = source[p];
}
}