summaryrefslogtreecommitdiffstats
path: root/geometry.c
diff options
context:
space:
mode:
Diffstat (limited to 'geometry.c')
-rw-r--r--geometry.c18
1 files changed, 18 insertions, 0 deletions
diff --git a/geometry.c b/geometry.c
index 322deee..057fea0 100644
--- a/geometry.c
+++ b/geometry.c
@@ -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;