summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/analysis_tools.cpp6
-rw-r--r--src/animate.cpp48
2 files changed, 26 insertions, 28 deletions
diff --git a/src/analysis_tools.cpp b/src/analysis_tools.cpp
index 1e799bb..34e4ea0 100644
--- a/src/analysis_tools.cpp
+++ b/src/analysis_tools.cpp
@@ -102,12 +102,10 @@ std::list<unsigned int> find_minimal_crack(const Graph& G, const network& n) {
std::array<unsigned int, 2> crossing_count{0,0};
for (auto edge : cycle) {
- double dx = fabs(n.G.dual_vertices[n.G.dual_edges[edge].v[0]].r.x - n.G.dual_vertices[n.G.dual_edges[edge].v[1]].r.x);
- if (dx > n.G.L.x / 2) {
+ if (n.G.dual_edges[edge].crossings[0]) {
crossing_count[0]++;
}
- double dy = fabs(n.G.dual_vertices[n.G.dual_edges[edge].v[0]].r.y - n.G.dual_vertices[n.G.dual_edges[edge].v[1]].r.y);
- if (dy > n.G.L.y / 2) {
+ if (n.G.dual_edges[edge].crossings[1]) {
crossing_count[1]++;
}
}
diff --git a/src/animate.cpp b/src/animate.cpp
index 26f4996..a24f0f2 100644
--- a/src/animate.cpp
+++ b/src/animate.cpp
@@ -25,15 +25,15 @@ void animate::pre_fracture(const network &n) {
graph::coordinate r1 = n.G.vertices[n.G.edges[i].v[0]].r;
graph::coordinate r2 = n.G.vertices[n.G.edges[i].v[1]].r;
- if (fabs(r1.x - r2.x) > n.G.L.x / 2) {
- if (r1.x < n.G.L.x / 2) {
+ if (n.G.edges[i].crossings[0]) {
+ if (r1.x < r2.x) {
r1.x += n.G.L.x;
} else {
r2.x += n.G.L.x;
}
}
- if (fabs(r1.y - r2.y) > n.G.L.y / 2) {
- if (r1.y < n.G.L.y / 2) {
+ if (n.G.edges[i].crossings[1]) {
+ if (r1.y < r2.y) {
r1.y += n.G.L.y;
} else {
r2.y += n.G.L.y;
@@ -63,16 +63,16 @@ void animate::bond_broken(const network& n, const current_info& cur, unsigned in
graph::coordinate r1 = n.G.vertices[n.G.edges[i].v[0]].r;
graph::coordinate r2 = n.G.vertices[n.G.edges[i].v[1]].r;
- if (fabs(r1.x - r2.x) > n.G.L.x / 2) {
- if (r1.x < n.G.L.x / 2) {
- r2.x -= n.G.L.x;
+ if (n.G.edges[i].crossings[0]) {
+ if (r1.x < r2.x) {
+ r1.x += n.G.L.x;
} else {
r2.x += n.G.L.x;
}
}
- if (fabs(r1.y - r2.y) > n.G.L.y / 2) {
- if (r1.y < n.G.L.y / 2) {
- r2.y -= n.G.L.y;
+ if (n.G.edges[i].crossings[1]) {
+ if (r1.y < r2.y) {
+ r1.y += n.G.L.y;
} else {
r2.y += n.G.L.y;
}
@@ -111,20 +111,20 @@ void animate::post_fracture(network &n) {
graph::coordinate r1 = n.G.vertices[n.G.edges[i].v[0]].r;
graph::coordinate r2 = n.G.vertices[n.G.edges[i].v[1]].r;
- if (fabs(r1.x - r2.x) > n.G.L.x / 2) {
- if (r1.x < n.G.L.x / 2) {
- r1.x += n.G.L.x;
- } else {
- r2.x += n.G.L.x;
- }
- }
- if (fabs(r1.y - r2.y) > n.G.L.y / 2) {
- if (r1.y < n.G.L.y / 2) {
- r1.y += n.G.L.y;
- } else {
- r2.y += n.G.L.y;
- }
- }
+ if (n.G.edges[i].crossings[0]) {
+ if (r1.x < r2.x) {
+ r1.x += n.G.L.x;
+ } else {
+ r2.x += n.G.L.x;
+ }
+ }
+ if (n.G.edges[i].crossings[1]) {
+ if (r1.y < r2.y) {
+ r1.y += n.G.L.y;
+ } else {
+ r2.y += n.G.L.y;
+ }
+ }
glVertex2d(r1.x, r1.y);
glVertex2d(r2.x, r2.y);