51 #define D ((ax2 - ax1) * (by1 - by2) - (ay2 - ay1) * (bx1 - bx2))
53 #define D1 ((bx1 - ax1) * (by1 - by2) - (by1 - ay1) * (bx1 - bx2))
55 #define D2 ((ax2 - ax1) * (by1 - ay1) - (ay2 - ay1) * (bx1 - ax1))
58 double bx1,
double by1,
double bx2,
double by2)
60 register double d, d1, d2;
64 if (ax1 > ax2 || (ax1 == ax2 && ay1 > ay2)) {
74 if (bx1 > bx2 || (bx1 == bx2 && by1 > by2)) {
87 else if (bx1 == ax1) {
90 else if (bx2 == ax2) {
93 else if (by1 == ay1) {
121 return (d1 >= 0 && d2 >= 0 && d >= d1 && d >= d2);
123 return (d1 <= 0 && d2 <= 0 && d <= d1 && d <= d2);
150 if (ay1 == by2 || ay2 == by1)
173 if (ax1 == bx2 || ax2 == bx1)
182 double bx1,
double by1,
double bx2,
double by2,
183 double *
x,
double *y)
185 register double d, r1, r2;
189 if (ax1 > ax2 || (ax1 == ax2 && ay1 > ay2)) {
199 if (bx1 > bx2 || (bx1 == bx2 && by1 > by2)) {
212 else if (bx1 == ax1) {
215 else if (bx2 == ax2) {
218 else if (by1 == ay1) {
247 if (r1 < 0 || r1 > 1 || r2 < 0 || r2 > 1) {
250 *
x = ax1 + r1 * (ax2 - ax1);
251 *y = ay1 + r1 * (ay2 - ay1);
283 if (ay1 > by1 && ay1 < by2) {
313 if (ax1 > bx1 && ax1 < bx2) {
int dig_find_intersection(double ax1, double ay1, double ax2, double ay2, double bx1, double by1, double bx2, double by2, double *x, double *y)
int dig_test_for_intersection(double ax1, double ay1, double ax2, double ay2, double bx1, double by1, double bx2, double by2)