#ifndef LINE_H_ #define LINE_H_ #include "Vertex.h" #include #define INTERSECTION_ERROR -1 #define INTERSECTION_NONE 0 #define INTERSECTION_IDENTICAL 1 #define INTERSECTION_LINE 2 #define INTERSECTION_LINE_LINE 2 #define INTERSECTION_LINE_SEGMENT 3 #define INTERSECTION_SEGMENT_LINE 6 #define INTERSECTION_SEGMENT_SEGMENT 7 class Line { private: Vertex v1, v2; public: Line() {} Line(const Vertex& v1, const Vertex& v2) { this->v1 = v1; this->v2 = v2; } Line(double x1, double y1, double x2, double y2) { v1.setLocation(x1, y1); v2.setLocation(x2, y2); } Vertex &getVertex1() {return v1;} const Vertex &getVertex1() const {return v1;} void setVertex1(const Vertex &v) {v1 = v;} Vertex &getVertex2() {return v2;} const Vertex &getVertex2() const {return v2;} void setVertex2(const Vertex &v) {v2 = v;} double lengthSq() const {return v1.distanceSq(v2);} double length() const {return sqrt(lengthSq());} bool contains(const Vertex &v) const; int intersects(const Line &l, Vertex *v) const; }; #endif /*LINE_H_*/