summaryrefslogtreecommitdiffstats
path: root/Vertex.h
diff options
context:
space:
mode:
Diffstat (limited to 'Vertex.h')
-rw-r--r--Vertex.h31
1 files changed, 31 insertions, 0 deletions
diff --git a/Vertex.h b/Vertex.h
new file mode 100644
index 0000000..e7d47ce
--- /dev/null
+++ b/Vertex.h
@@ -0,0 +1,31 @@
+#ifndef VERTEX_H_
+#define VERTEX_H_
+
+class Vertex {
+ private:
+ double x, y;
+ public:
+ Vertex() {x = y = 0.0;}
+ Vertex(const Vertex &v) {x = v.x; y = v.y;}
+ Vertex(double x, double y) {this->x = x; this->y = y;}
+
+ double getX() const {return x;}
+ void setX(double x) {this->x = x;}
+
+ double getY() const {return y;}
+ void setY(double y) {this->y = y;}
+
+ void setLocation(const Vertex &v) {x = v.x; y = v.y;}
+ void setLocation(double x, double y) {this->x = x; this->y = y;}
+
+ double distanceSq(const Vertex &v) const;
+ double distance(const Vertex &v) const;
+
+ Vertex operator+(const Vertex &v) const;
+ Vertex operator-(const Vertex &v) const;
+
+ Vertex& operator+=(const Vertex &v);
+ Vertex& operator-=(const Vertex &v);
+};
+
+#endif /*VERTEX_H_*/