Index: cdt.c =================================================================== --- cdt.c (revision 18137) +++ cdt.c (revision 18138) @@ -18,21 +18,7 @@ #define LEFTPOINT(p1, p2) ((p1)->pos.x < (p2)->pos.x || ((p1)->pos.x == (p2)->pos.x && (p1)->pos.y > (p2)->pos.y)) -#define ORIENT_CCW(a, b, c) (orientation(a, b, c) < 0) -#define ORIENT_CW(a, b, c) (orientation(a, b, c) > 0) -/* TODO: check epsilon for collinear case? */ -#define ORIENT_COLLINEAR(a, b, c) (orientation(a, b, c) == 0) -#define ORIENT_CCW_CL(a, b, c) (orientation(a, b, c) <= 0) -static double orientation(point_t *p1, point_t *p2, point_t *p3) -{ - return ((double)p2->pos.y - (double)p1->pos.y) * ((double)p3->pos.x - (double)p2->pos.x) - - ((double)p2->pos.x - (double)p1->pos.x) * ((double)p3->pos.y - (double)p2->pos.y); -} -#define LINES_INTERSECT(p1, q1, p2, q2) \ - (ORIENT_CCW(p1, q1, p2) != ORIENT_CCW(p1, q1, q2) && ORIENT_CCW(p2, q2, p1) != ORIENT_CCW(p2, q2, q1)) - - static point_t *new_point(cdt_t *cdt, pos_t pos) { point_t *p = *vtpoint_alloc_append(&cdt->points, 1); Index: cdt.h =================================================================== --- cdt.h (revision 18137) +++ cdt.h (revision 18138) @@ -38,4 +38,19 @@ int cdt_check_delaunay(cdt_t *cdt, pointlist_node_t **point_violations, trianglelist_node_t **triangle_violations); void cdt_dump_animator(cdt_t *cdt, int show_circles, pointlist_node_t *point_violations, trianglelist_node_t *triangle_violations); + +#define ORIENT_CCW(a, b, c) (orientation(a, b, c) < 0) +#define ORIENT_CW(a, b, c) (orientation(a, b, c) > 0) +/* TODO: check epsilon for collinear case? */ +#define ORIENT_COLLINEAR(a, b, c) (orientation(a, b, c) == 0) +#define ORIENT_CCW_CL(a, b, c) (orientation(a, b, c) <= 0) +static inline double orientation(point_t *p1, point_t *p2, point_t *p3) +{ + return ((double)p2->pos.y - (double)p1->pos.y) * ((double)p3->pos.x - (double)p2->pos.x) + - ((double)p2->pos.x - (double)p1->pos.x) * ((double)p3->pos.y - (double)p2->pos.y); +} + +#define LINES_INTERSECT(p1, q1, p2, q2) \ + (ORIENT_CCW(p1, q1, p2) != ORIENT_CCW(p1, q1, q2) && ORIENT_CCW(p2, q2, p1) != ORIENT_CCW(p2, q2, q1)) + #endif