diff options
Diffstat (limited to 'geometry.c')
-rw-r--r-- | geometry.c | 18 |
1 files changed, 18 insertions, 0 deletions
@@ -140,7 +140,10 @@ int lineIntersection(const LINE *la, const LINE *lb, VERTEX *v) { double xb2 = lb->v2.x, yb2 = lb->v2.y; double temp; int switched = 0; + VERTEX v2; + + if(v == NULL) v = &v2; if(xa1 == xa2 && ya1 == ya2) return INTERSECTION_ERROR; if(xb1 == xb2 && yb1 == yb2) return INTERSECTION_ERROR; @@ -227,6 +230,21 @@ int lineRectIntersections(const LINE *line, const RECTANGLE *rect, int edge, VER return ret; } +gboolean linePolygonIntersection(const LINE *l, const POLYGON *p) { + int i; + LINE line; + + for(i = 0; i < p->nVertices; i++) { + line.v1 = p->vertices[i]; + line.v2 = p->vertices[(i+1)%p->nVertices]; + + if(lineIntersection(l, &line, NULL) == INTERSECTION_SEGMENT_SEGMENT) + return TRUE; + } + + return FALSE; +} + void simplifyPolygon(const POLYGON *in, const RECTANGLE *rect, POLYGON *out) { int i, j; int a; |