while (alpha[i]<-M_PI/2) { alpha[i]+=M_PI; rs[i].reversed = !rs[i].reversed; }
while (alpha[i]>M_PI/2) { alpha[i]-=M_PI; rs[i].reversed = !rs[i].reversed; }
#ifdef RECOGNIZER_DEBUG
while (alpha[i]<-M_PI/2) { alpha[i]+=M_PI; rs[i].reversed = !rs[i].reversed; }
while (alpha[i]>M_PI/2) { alpha[i]-=M_PI; rs[i].reversed = !rs[i].reversed; }
#ifdef RECOGNIZER_DEBUG
dist = hypot(pt[0]-(rs[j].reversed?rs[j].x1:rs[j].x2),
pt[1]-(rs[j].reversed?rs[j].y1:rs[j].y2));
#ifdef RECOGNIZER_DEBUG
dist = hypot(pt[0]-(rs[j].reversed?rs[j].x1:rs[j].x2),
pt[1]-(rs[j].reversed?rs[j].y1:rs[j].y2));
#ifdef RECOGNIZER_DEBUG
#endif
if (dist>ARROW_TIP_LINEAR_TOLERANCE*rs[j].radius) return FALSE;
}
dist = (pt[0]-x2)*sin(angle)-(pt[1]-y2)*cos(angle);
dist /= rs[1].radius + rs[2].radius;
#ifdef RECOGNIZER_DEBUG
#endif
if (dist>ARROW_TIP_LINEAR_TOLERANCE*rs[j].radius) return FALSE;
}
dist = (pt[0]-x2)*sin(angle)-(pt[1]-y2)*cos(angle);
dist /= rs[1].radius + rs[2].radius;
#ifdef RECOGNIZER_DEBUG
#endif
if (fabs(dist)>ARROW_SIDEWAYS_GAP_TOLERANCE) return FALSE;
dist = (pt[0]-x2)*cos(angle)+(pt[1]-y2)*sin(angle);
dist /= rs[1].radius + rs[2].radius;
#ifdef RECOGNIZER_DEBUG
#endif
if (fabs(dist)>ARROW_SIDEWAYS_GAP_TOLERANCE) return FALSE;
dist = (pt[0]-x2)*cos(angle)+(pt[1]-y2)*sin(angle);
dist /= rs[1].radius + rs[2].radius;
#ifdef RECOGNIZER_DEBUG
it = undo->item;
calc_inertia(it->path->coords, 0, it->path->num_points-1, &s);
#ifdef RECOGNIZER_DEBUG
it = undo->item;
calc_inertia(it->path->coords, 0, it->path->num_points-1, &s);
#ifdef RECOGNIZER_DEBUG
- printf("Mass=%.0f, Center=(%.1f,%.1f), I=(%.0f,%.0f, %.0f), "
+ printf("DEBUG: Mass=%.0f, Center=(%.1f,%.1f), I=(%.0f,%.0f, %.0f), "
"Rad=%.2f, Det=%.4f \n",
s.mass, center_x(s), center_y(s), I_xx(s), I_yy(s), I_xy(s), I_rad(s), I_det(s));
#endif
"Rad=%.2f, Det=%.4f \n",
s.mass, center_x(s), center_y(s), I_xx(s), I_yy(s), I_xy(s), I_rad(s), I_det(s));
#endif
if (n>0) {
optimize_polygonal(it->path->coords, n, brk, ss);
#ifdef RECOGNIZER_DEBUG
if (n>0) {
optimize_polygonal(it->path->coords, n, brk, ss);
#ifdef RECOGNIZER_DEBUG
- printf("%d-%d (M=%.0f, det=%.4f) ", brk[i], brk[i+1], ss[i].mass, I_det(ss[i]));
+ printf("DEBUG: %d-%d (M=%.0f, det=%.4f) ", brk[i], brk[i+1], ss[i].mass, I_det(ss[i]));
if (I_det(s)>CIRCLE_MIN_DET) {
score = score_circle(it->path->coords, 0, it->path->num_points-1, &s);
#ifdef RECOGNIZER_DEBUG
if (I_det(s)>CIRCLE_MIN_DET) {
score = score_circle(it->path->coords, 0, it->path->num_points-1, &s);
#ifdef RECOGNIZER_DEBUG
#endif
if (score < CIRCLE_MAX_SCORE) {
make_circle_shape(center_x(s), center_y(s), I_rad(s));
#endif
if (score < CIRCLE_MAX_SCORE) {
make_circle_shape(center_x(s), center_y(s), I_rad(s));