summaryrefslogtreecommitdiffstats
path: root/geometry.h
blob: cefd9a3c65daa0014de70634ff0d49deb75bc847 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#ifndef GEOMETRY_H_
#define GEOMETRY_H_


#include "Vertex.h"
#include "Polygon.h"
#include "Line.h"
#include <glib.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)




typedef struct _RECTANGLE {
  double x, y, width, height;
} RECTANGLE;


int vertexOnLine(const Vertex *v, const LINE *l);
int vertexInRect(const Vertex *v, const RECTANGLE *rect);


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);
//gboolean linePolygonIntersection(const LINE *l, const POLYGON *p);
void simplifyPolygon(const Polygon *in, const RECTANGLE *rect, Polygon *out);

#endif /*GEOMETRY_H_*/