20 double ul[2],
double ur[2],
double ll[2],
double lr[2]);
61 double ul[2],
double ur[2],
double ll[2],
double lr[2]) {
63 ll[0] = obbox->
pose[0];
64 ll[1] = obbox->
pose[1];
65 lr[0] = obbox->
pose[0] + obbox->
size[0] * cos(obbox->
pose[2]);
66 lr[1] = obbox->
pose[1] + obbox->
size[0] * sin(obbox->
pose[2]);
69 ur[0] = ul[0] + obbox->
size[0] * cos(obbox->
pose[2]);
70 ur[1] = ul[1] + obbox->
size[0] * sin(obbox->
pose[2]);
75 double ul[2], ur[2], ll[2], lr[2];
86 double ul[2], ur[2], ll[2], lr[2];
90 sm_error(
"Could not compute bounding box.\n");
93 bbox->
pose[0] = ll[0];
94 bbox->
pose[1] = ll[1];
95 bbox->
pose[2] = atan2(lr[1]-ll[1], lr[0]-ll[0]);
99 double bb_min[2] = {bbf->
buf[0].
x,bbf->
buf[0].
y},
100 bb_max[2] = {bbf->
buf[0].
x,bbf->
buf[0].
y};
101 int i;
for(i=0;i<bbf->
num; i++) {
102 bb_min[0] = GSL_MIN(bb_min[0], bbf->
buf[i].
x);
103 bb_min[1] = GSL_MIN(bb_min[1], bbf->
buf[i].
y);
104 bb_max[0] = GSL_MAX(bb_max[0], bbf->
buf[i].
x);
105 bb_max[1] = GSL_MAX(bb_max[1], bbf->
buf[i].
y);
107 bbox->
pose[0] = bb_min[0];
108 bbox->
pose[1] = bb_min[1];
110 bbox->
size[0] = bb_max[0] - bb_min[0];
111 bbox->
size[1] = bb_max[1] - bb_min[1];
123 int i;
for(i=0;i<ld->
nrays;i++) {
124 if(!ld->
valid[i])
continue;
125 if(ld->
readings[i]>horizon)
continue;
140 double ul[2], ur[2], ll[2], lr[2];
151 double ul[2],
double ur[2],
double ll[2],
double lr[2]) {
157 for (
int i=0; i < nOfPoints; i++) {
161 centerx /= (double) nOfPoints;
162 centery /= (double) nOfPoints;
174 for (
int i=0; i < nOfPoints; i++) {
175 double cix = p[i].
x - centerx;
176 double ciy = p[i].
y - centery;
182 x1 /= (double) nOfPoints;
183 x2 /= (double) nOfPoints;
185 x4 /= (double) nOfPoints;
192 if ((x3 == 0) || (x2 == 0)|| (x4*x4-2*x1*x4+x1*x1+4*x2*x3 < 0 )) {
193 sm_error(
"Cyrill: Could not compute bounding box.\n");
198 double lamda1 = 0.5* (x4 + x1 + sqrt(x4*x4 - 2.0*x1*x4 + x1*x1 + 4.0*x2*x3));
199 double lamda2 = 0.5* (x4 + x1 - sqrt(x4*x4 - 2.0*x1*x4 + x1*x1 + 4.0*x2*x3));
202 double v1x = - (x4-lamda1) * (x4-lamda1) * (x1-lamda1) / (x2 * x3 * x3);
203 double v1y = (x4-lamda1) * (x1-lamda1) / (x2 * x3);
205 double v2x = - (x4-lamda2) * (x4-lamda2) * (x1-lamda2) / (x2 * x3 * x3);
206 double v2y = (x4-lamda2) * (x1-lamda2) / (x2 * x3);
209 double lv1 = sqrt ( (v1x*v1x) + (v1y*v1y) );
210 double lv2 = sqrt ( (v2x*v2x) + (v2y*v2y) );
224 for(
int i = 0; i< nOfPoints; i++) {
226 x = (p[i].
x - centerx) * v1x + (p[i].y - centery) * v1y;
227 y = (p[i].
x - centerx) * v2x + (p[i].y - centery) * v2y;
229 if( x > xmax) xmax = x;
230 if( x < xmin) xmin = x;
231 if( y > ymax) ymax = y;
232 if( y < ymin) ymin = y;
237 ul[0] = centerx + xmin * v1x + ymin * v2x;
238 ul[1] = centery + xmin * v1y + ymin * v2y;
242 ur[0] = centerx + xmax * v1x + ymin * v2x;
243 ur[1] = centery + xmax * v1y + ymin * v2y;
247 ll[0] = centerx + xmin * v1x + ymax * v2x;
248 ll[1] = centery + xmin * v1y + ymax * v2y;
252 lr[0] = centerx + xmax * v1x + ymax * v2x;
253 lr[1] = centery + xmax * v1y + ymax * v2y;
int bbfind_add_point(bbfind *bbf, double point[2])
int bbfind_add_point2(bbfind *bbf, double x, double y)
void ld_get_oriented_bbox(LDP ld, double horizon, oriented_bbox *obbox)
double *restrict readings
int bbfind_add_bbox(bbfind *bbf, const BB2 bbox)
void bbfind_free(bbfind *bbf)
double getBoundingBoxArea(BB_Point *p, int nOfPoints)
double distance_d(const double a[2], const double b[2])
bbfind * bbfind_new(void)
int getBoundingBox(BB_Point *p, int nOfPoints, double ul[2], double ur[2], double ll[2], double lr[2])
void oriented_bbox_compute_corners(const BB2 obbox, double ul[2], double ur[2], double ll[2], double lr[2])
int bbfind_compute(bbfind *bbf, BB2 bbox)
void sm_error(const char *msg,...)