summaryrefslogtreecommitdiffstats
path: root/Polygon.h
diff options
context:
space:
mode:
Diffstat (limited to 'Polygon.h')
-rw-r--r--Polygon.h22
1 files changed, 22 insertions, 0 deletions
diff --git a/Polygon.h b/Polygon.h
index 093a160..6e36bee 100644
--- a/Polygon.h
+++ b/Polygon.h
@@ -3,17 +3,39 @@
#include "Vertex.h"
#include "Line.h"
+#include "Triangle.h"
#include <vector>
class Polygon : public std::vector<Vertex> {
private:
+ struct Intersection {
+ size_t va1, va2, vb1, vb2;
+ Vertex v;
+ };
+
+ typedef Triangle::Direction Direction;
+
int quadrant(const Vertex &v) const;
+
+ double signedArea() const;
+
+ Triangle::Direction getDirection() const;
+ bool isConcave(const Triangle::Direction &dir, const Vertex &v1, const Vertex &v2, const Vertex &v3) const;
+
+ bool intersections(std::vector<Intersection> *intersections = NULL) const;
+
+ void doTriangulate(std::vector<Triangle> &triangles) const;
public:
double area() const;
double perimeter() const;
bool contains(const Vertex &v) const;
bool intersects(const Line &l) const;
+
+ bool isSimple() const;
+ bool simplify(Polygon &polygon) const;
+
+ void triangulate(std::vector<Triangle> &triangles) const;
};
#endif /*POLYGON_H_*/