summaryrefslogtreecommitdiffstats
path: root/geometry.h
diff options
context:
space:
mode:
authorneoraider <devnull@localhost>2007-06-23 21:00:05 +0200
committerneoraider <devnull@localhost>2007-06-23 21:00:05 +0200
commit6c9c0b8a29cd0eb64e3f1103ca3363ccff7b3eba (patch)
tree45e4f6924df19fa17f53689f3ac6160e606af086 /geometry.h
parent2a3c0deaa51d91c41dc26ee89f55eff1792cb2f3 (diff)
downloadzoomedit-6c9c0b8a29cd0eb64e3f1103ca3363ccff7b3eba.tar
zoomedit-6c9c0b8a29cd0eb64e3f1103ca3363ccff7b3eba.zip
zoomedit: Implemented geometry functions.
Diffstat (limited to 'geometry.h')
-rw-r--r--geometry.h50
1 files changed, 50 insertions, 0 deletions
diff --git a/geometry.h b/geometry.h
new file mode 100644
index 0000000..c936e59
--- /dev/null
+++ b/geometry.h
@@ -0,0 +1,50 @@
+#ifndef GEOMETRY_H_
+#define GEOMETRY_H_
+
+
+#define EDGE_NONE 0
+#define EDGE_LEFT (1<<0)
+#define EDGE_RIGHT (1<<1)
+#define EDGE_TOP (1<<2)
+#define EDGE_BOTTOM (1<<3)
+#define EDGE_ALL (EDGE_LEFT|EDGE_RIGHT|EDGE_TOP|EDGE_BOTTOM)
+
+#define INTERSECTION_ERROR -1
+#define INTERSECTION_NONE 0
+#define INTERSECTION_IDENTICAL 1
+#define INTERSECTION_LINE_LINE 2
+#define INTERSECTION_LINE_SEGMENT 3
+#define INTERSECTION_SEGMENT_LINE 4
+#define INTERSECTION_SEGMENT_SEGMENT 5
+
+
+typedef struct _VERTEX {
+ double x, y;
+} VERTEX;
+
+typedef struct _RECTANGLE {
+ double x, y, width, height;
+} RECTANGLE;
+
+typedef struct _LINE {
+ VERTEX v1, v2;
+} LINE;
+
+typedef struct _VERTEX_LIST {
+ unsigned int nVertices;
+ VERTEX *vertices;
+} VERTEX_LIST, POLYGON;
+
+
+void addVertex(VERTEX_LIST *list, VERTEX *v);
+void insertVertex(VERTEX_LIST *list, VERTEX *v, unsigned int n);
+void deleteVertex(VERTEX_LIST *list, unsigned int n);
+
+
+int vertexInRect(const VERTEX *v, const RECTANGLE *rect);
+int lineIntersection(const LINE *la, const LINE *lb, VERTEX *v);
+int lineRectIntersection(const LINE *l, const RECTANGLE *rect, int edge, VERTEX *v);
+int lineRectIntersections(const LINE *line, const RECTANGLE *rect, int edge, VERTEX *v1, VERTEX *v2);
+void simplifyPolygon(const POLYGON *in, const RECTANGLE *rect, POLYGON *out);
+
+#endif /*GEOMETRY_H_*/