summaryrefslogtreecommitdiff
path: root/lib/src/graph.cpp
diff options
context:
space:
mode:
authorJaron Kent-Dobias <jaron@kent-dobias.com>2019-11-12 11:38:29 -0500
committerJaron Kent-Dobias <jaron@kent-dobias.com>2019-11-12 11:38:29 -0500
commit0a79391dc49a9662100969e53b55fef4d367df77 (patch)
treea84704ef2c37a8ae43a47fc92af38add8bb5804f /lib/src/graph.cpp
parent8c1b1a60656f21d206f6c7c188923df06b646ca5 (diff)
downloadfuse_networks-0a79391dc49a9662100969e53b55fef4d367df77.tar.gz
fuse_networks-0a79391dc49a9662100969e53b55fef4d367df77.tar.bz2
fuse_networks-0a79391dc49a9662100969e53b55fef4d367df77.zip
more progress on crack stress
Diffstat (limited to 'lib/src/graph.cpp')
-rw-r--r--lib/src/graph.cpp30
1 files changed, 25 insertions, 5 deletions
diff --git a/lib/src/graph.cpp b/lib/src/graph.cpp
index c75d466..1c770e9 100644
--- a/lib/src/graph.cpp
+++ b/lib/src/graph.cpp
@@ -445,14 +445,14 @@ void graph::helper(unsigned nv, std::mt19937& rng) {
jcv_diagram_free(&diagram);
}
-graph::coordinate reverse(const graph::coordinate& x) { return {x.y, x.x}; }
+coordinate reverse(const coordinate& x) { return {x.y, x.x}; }
graph const graph::rotate() {
graph g2(*this);
for (graph::vertex& v : g2.vertices) {
v.r = reverse(v.r);
- for (graph::coordinate& r : v.polygon) {
+ for (coordinate& r : v.polygon) {
r = reverse(r);
}
}
@@ -464,7 +464,7 @@ graph const graph::rotate() {
for (graph::vertex& v : g2.dual_vertices) {
v.r = reverse(v.r);
- for (graph::coordinate& r : v.polygon) {
+ for (coordinate& r : v.polygon) {
r = reverse(r);
}
}
@@ -490,7 +490,7 @@ std::string graph::write() const {
output += "},\"vp\"->{";
for (const graph::vertex &v : vertices) {
output += "{";
- for (const graph::coordinate &r : v.polygon) {
+ for (const coordinate &r : v.polygon) {
output += "{" + std::to_string(r.x) + "," + std::to_string(r.y) + "},";
}
output.pop_back();
@@ -505,7 +505,7 @@ std::string graph::write() const {
output += "},\"up\"->{";
for (const graph::vertex &v : dual_vertices) {
output += "{";
- for (const graph::coordinate &r : v.polygon) {
+ for (const coordinate &r : v.polygon) {
output += "{" + std::to_string(r.x) + "," + std::to_string(r.y) + "},";
}
output.pop_back();
@@ -536,3 +536,23 @@ std::string graph::write() const {
return output;
}
+
+coordinate graph::Δr(unsigned e) const {
+ coordinate tmp = dual_vertices[dual_edges[e].v[1]].r - dual_vertices[dual_edges[e].v[0]].r;
+ if (dual_edges[e].crossings[0]) {
+ if (tmp.x > 0) {
+ tmp.x -= L.x;
+ } else {
+ tmp.x += L.x;
+ }
+ }
+ if (dual_edges[e].crossings[1]) {
+ if (tmp.y > 0) {
+ tmp.y -= L.y;
+ } else {
+ tmp.y += L.y;
+ }
+ }
+
+ return tmp;
+}