From 0a79391dc49a9662100969e53b55fef4d367df77 Mon Sep 17 00:00:00 2001 From: Jaron Kent-Dobias Date: Tue, 12 Nov 2019 11:38:29 -0500 Subject: more progress on crack stress --- lib/include/graph.hpp | 43 ++++++++++++++++++++++++++++++++++++++----- 1 file changed, 38 insertions(+), 5 deletions(-) (limited to 'lib/include') 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 + 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 nd; @@ -49,4 +80,6 @@ public: graph const rotate(); std::string write() const; + + coordinate Δr(unsigned e) const; }; -- cgit v1.2.3-70-g09d2