Returns T iff (a,b,c) are collinear and point c lies on the closed segement ab.
| 210 | // Returns T iff (a,b,c) are collinear and point c lies |
| 211 | // on the closed segement ab. |
| 212 | static bool between(const int* a, const int* b, const int* c) |
| 213 | { |
| 214 | if (!collinear(a, b, c)) |
| 215 | return false; |
| 216 | // If ab not vertical, check betweenness on x; else on y. |
| 217 | if (a[0] != b[0]) |
| 218 | return ((a[0] <= c[0]) && (c[0] <= b[0])) || ((a[0] >= c[0]) && (c[0] >= b[0])); |
| 219 | else |
| 220 | return ((a[2] <= c[2]) && (c[2] <= b[2])) || ((a[2] >= c[2]) && (c[2] >= b[2])); |
| 221 | } |
| 222 | |
| 223 | // Returns true iff segments ab and cd intersect, properly or improperly. |
| 224 | static bool intersect(const int* a, const int* b, const int* c, const int* d) |