27#define D ((ax2 - ax1) * (by1 - by2) - (ay2 - ay1) * (bx1 - bx2))
28#define DA ((bx1 - ax1) * (by1 - by2) - (by1 - ay1) * (bx1 - bx2))
29#define DB ((ax2 - ax1) * (by1 - ay1) - (ay2 - ay1) * (bx1 - ax1))
31#ifdef ASDASDASFDSAFFDAS
89void swap(
double *a,
double *
b)
101 double *x1,
double *y1,
double *x2,
double *y2)
123 G_debug(3,
"segment_intersection_2d_e()");
136 G_debug(3,
" identical segments");
145 G_debug(3,
" connected by endpoints");
151 G_debug(3,
" connected by endpoints");
158 G_debug(3,
" no intersection (disjoint bounding boxes)");
162 G_debug(3,
" no intersection (disjoint bounding boxes)");
169 G_debug(3,
" general position");
184 G_debug(3,
" no intersection");
191 G_debug(3,
" no intersection");
197 G_debug(3,
" no intersection");
204 G_debug(3,
" no intersection");
225 G_debug(3,
" intersection %.16g, %.16g", *x1, *y1);
234 G_debug(3,
" parallel segments");
265 G_debug(3,
" collinear segments");
268 G_debug(3,
" no intersection");
312 G_debug(3,
" partial overlap");
345 G_warning((
"segment_intersection_2d() ERROR (should not be reached)"));
361 double *x1,
double *y1,
double *x2,
double *y2,
371 G_debug(4,
"segment_intersection_2d()");
382 G_debug(2,
" -> identical segments");
438 G_debug(2,
" not parallel/collinear: ra = %.18g",
ra);
443 G_debug(2,
" no intersection");
451 G_debug(2,
" intersection %.18f, %.18f", *x1, *y1);
456 G_debug(3,
" -> parallel/collinear");
475 G_debug(2,
" -> collinear vertical");
487 G_debug(2,
" -> no intersection");
495 G_debug(2,
" -> connected by end points");
501 G_debug(2,
" -> connected by end points");
506 G_debug(3,
" -> vertical overlap");
509 G_debug(2,
" -> a contains b");
521 G_debug(2,
" -> b contains a");
533 G_debug(2,
" -> partial overlap");
568 "Vect_segment_intersection() ERROR (collinear vertical segments)"));
577 G_debug(2,
" -> collinear non vertical");
582 G_debug(2,
" -> no intersection");
587 G_debug(2,
" -> overlap/connected end points");
593 G_debug(2,
" -> connected by end points");
599 G_debug(2,
" -> connected by end points");
622 G_debug(2,
" -> a contains b");
634 G_debug(2,
" -> b contains a");
646 G_debug(2,
" -> partial overlap");
680 (
"segment_intersection_2d() ERROR (collinear non vertical segments)"));
692 double *x1,
double *y1,
double *x2,
double *y2)
738 G_debug(
DLEVEL,
" no intersection (disjoint bounding boxes)");
742 G_debug(
DLEVEL,
" no intersection (disjoint bounding boxes)");
786 if ((
da < 0) || (
da > d)) {
792 if ((
db < 0) || (
db > d)) {
798 if ((
da > 0) || (
da < d)) {
804 if ((
db > 0) || (
db < d)) {
826 if ((
da != 0) || (
db != 0)) {
914 G_warning((
"segment_intersection_2d() ERROR (should not be reached)"));
933 if (a == 0 ||
b == 0) {
949 double *x1,
double *y1,
double *x2,
double *y2)
973 G_debug(3,
"segment_intersection_2d_test()");
986 G_debug(4,
" identical segments");
995 G_debug(4,
" connected by endpoints");
1001 G_debug(4,
" connected by endpoints");
1008 G_debug(4,
" no intersection (disjoint bounding boxes)");
1012 G_debug(4,
" no intersection (disjoint bounding boxes)");
1023 G_debug(3,
" dd = %sE%d", (s[0] == 0) ?
"0" : s,
exp);
1027 G_debug(3,
" general position");
1040 G_debug(4,
" rra = %sE%d", (s[0] == 0) ?
"0" : s,
exp);
1043 G_debug(4,
" rrb = %sE%d", (s[0] == 0) ?
"0" : s,
exp);
1079 G_debug(2,
" intersection at:");
1080 G_debug(2,
" xx = %.18e", *x1);
1082 G_debug(2,
" yy = %.18e", *y1);
1087 G_debug(3,
" parallel/collinear...");
void G_warning(const char *,...) __attribute__((format(printf
int G_debug(int, const char *,...) __attribute__((format(printf
int segment_intersection_2d(double ax1, double ay1, double ax2, double ay2, double bx1, double by1, double bx2, double by2, double *x1, double *y1, double *x2, double *y2)
int segment_intersection_2d_tol(double ax1, double ay1, double ax2, double ay2, double bx1, double by1, double bx2, double by2, double *x1, double *y1, double *x2, double *y2, double tol)
int almost_equal(double a, double b, int bits)
#define FEQUAL(X, Y, TOL)