diff options
Diffstat (limited to 'lib/include/graph.hpp')
-rw-r--r-- | lib/include/graph.hpp | 43 |
1 files changed, 38 insertions, 5 deletions
diff --git a/lib/include/graph.hpp b/lib/include/graph.hpp index c78fe9f..5ad4c8b 100644 --- a/lib/include/graph.hpp +++ b/lib/include/graph.hpp @@ -13,13 +13,44 @@ #include "array_hash.hpp" -class graph { +class coordinate { public: - typedef struct coordinate { - double x; - double y; - } coordinate; + double x; + double y; + + coordinate operator+(const coordinate& r) const { + coordinate rp = {0, 0}; + rp.x = x + r.x; + rp.y = y + r.y; + + return rp; + } + + template <class T> + coordinate operator*(const T& a) const { + coordinate rp = *this; + rp.x *= a; + rp.y *= a; + return rp; + } + + coordinate operator-(const coordinate& r) const { + coordinate rp = *this; + return rp + (r * -1); + } + + coordinate operator-() const { + return *this * -1; + } + void operator+=(const coordinate& r) { + x += r.x; + y += r.y; + } +}; + +class graph { +public: typedef struct vertex { coordinate r; std::vector<unsigned> nd; @@ -49,4 +80,6 @@ public: graph const rotate(); std::string write() const; + + coordinate Δr(unsigned e) const; }; |