00001
00020 #ifndef OUTLINES_H
00021 #define OUTLINES_H
00022
00023 #include "blobs.h"
00024 #include "chop.h"
00025
00026 #include <math.h>
00027
00028
00029
00030
00032 #define LARGE_DISTANCE 100000
00033
00034 #define MIN_BLOB_SIZE 10
00035
00036 #define MAX_ASPECT_RATIO 2.5
00037
00038
00039
00040
00041
00046 #define same_point(p1,p2) \
00047 ((abs (p1.x - p2.x) < same_distance) && \
00048 (abs (p1.y - p2.y) < same_distance))
00049
00050
00055 #define dist_square(p1,p2) \
00056 ((p2.x - p1.x) * (p2.x - p1.x) + \
00057 (p2.y - p1.y) * (p2.y - p1.y))
00058
00059
00066 #define closest(test_p,p1,p2) \
00067 (p1 ? \
00068 (p2 ? \
00069 ((dist_square (test_p->pos, p1->pos) < \
00070 dist_square (test_p->pos, p2->pos)) ? \
00071 p1 : \
00072 p2) : \
00073 p1) : \
00074 p2)
00075
00076
00080 #define edgept_dist(p1,p2) \
00081 (dist_square ((p1)->pos, (p2)->pos))
00082
00083
00087 #define is_exterior_point(edge,point) \
00088 (same_point (edge->prev->pos, point->pos) || \
00089 same_point (edge->next->pos, point->pos) || \
00090 (angle_change (edge->prev, edge, edge->next) - \
00091 angle_change (edge->prev, edge, point) > 20))
00092
00093
00097 #define is_equal(p1,p2) \
00098 (((p1).x == (p2).x) && ((p1).y == (p2).y))
00099
00100
00108 #define is_on_line(p,p0,p1) \
00109 (within_range ((p).x, (p0).x, (p1).x) && \
00110 within_range ((p).y, (p0).y, (p1).y))
00111
00112
00118 #define within_range(x,x0,x1) \
00119 (((x0 <= x) && (x <= x1)) || ((x1 <= x) && (x <= x0)))
00120
00121
00122
00123
00124 int crosses_outline(EDGEPT *p0,
00125 EDGEPT *p1,
00126 EDGEPT *outline);
00127
00128 int is_crossed(TPOINT a0, TPOINT a1, TPOINT b0, TPOINT b1);
00129
00130 int is_same_edgept(EDGEPT *p1, EDGEPT *p2);
00131
00132 EDGEPT *near_point(EDGEPT *point, EDGEPT *line_pt_0, EDGEPT *line_pt_1);
00133
00134 void reverse_outline(EDGEPT *outline);
00135 #endif