summaryrefslogtreecommitdiff
path: root/lib/src
diff options
context:
space:
mode:
Diffstat (limited to 'lib/src')
-rw-r--r--lib/src/graph.cpp36
1 files changed, 18 insertions, 18 deletions
diff --git a/lib/src/graph.cpp b/lib/src/graph.cpp
index f59a817..0cc6a18 100644
--- a/lib/src/graph.cpp
+++ b/lib/src/graph.cpp
@@ -34,36 +34,36 @@ graph::graph(unsigned int Nx, unsigned int Ny) {
vertices[i].r.x = (double)((1 + i / (Nx / 2)) % 2 + 2 * (i % (Nx / 2)));
vertices[i].r.y = (double)(i / (Nx / 2));
vertices[i].polygon = {
- {vertices[i].r.x - 0.5, vertices[i].r.y},
- {vertices[i].r.x, vertices[i].r.y - 0.5},
- {vertices[i].r.x + 0.5, vertices[i].r.y},
- {vertices[i].r.x, vertices[i].r.y + 0.5}
+ {vertices[i].r.x - 1.0, vertices[i].r.y},
+ {vertices[i].r.x, vertices[i].r.y - 1.0},
+ {vertices[i].r.x + 1.0, vertices[i].r.y},
+ {vertices[i].r.x, vertices[i].r.y + 1.0}
};
dual_vertices[i].r.x = (double)((i / (Nx / 2)) % 2 + 2 * (i % (Nx / 2)));
dual_vertices[i].r.y = (double)(i / (Nx / 2));
dual_vertices[i].polygon = {
- {dual_vertices[i].r.x - 0.5, vertices[i].r.y},
- {dual_vertices[i].r.x, vertices[i].r.y - 0.5},
- {dual_vertices[i].r.x + 0.5, vertices[i].r.y},
- {dual_vertices[i].r.x, vertices[i].r.y + 0.5}
+ {dual_vertices[i].r.x - 1.0, vertices[i].r.y},
+ {dual_vertices[i].r.x, vertices[i].r.y - 1.0},
+ {dual_vertices[i].r.x + 1.0, vertices[i].r.y},
+ {dual_vertices[i].r.x, vertices[i].r.y + 1.0}
};
}
- for (unsigned int x = 0; x < Ny; x++) {
- for (unsigned int y = 0; y < Nx; y++) {
- unsigned int v1 = (Nx * x) / 2 + ((y + x % 2) / 2) % (Nx / 2);
- unsigned int v2 = ((Nx * (x + 1)) / 2 + ((y + (x + 1) % 2) / 2) % (Nx / 2)) % nv;
+ for (unsigned int y = 0; y < Ny; y++) {
+ for (unsigned int x = 0; x < Nx; x++) {
+ unsigned int v1 = (Nx * y) / 2 + ((x + y % 2) / 2) % (Nx / 2);
+ unsigned int v2 = ((Nx * (y + 1)) / 2 + ((x + (y + 1) % 2) / 2) % (Nx / 2)) % nv;
- bool crossed_x = y == Nx - 1;
- bool crossed_y = x == Ny - 1;
+ bool crossed_x = x == Nx - 1;
+ bool crossed_y = y == Ny - 1;
- edges.push_back({{v1, v2}, {0.5 + (double)y, 0.5 + (double)x}, {crossed_x, crossed_y}});
+ edges.push_back({{v1, v2}, {0.5 + (double)x, 0.5 + (double)y}, {crossed_x, crossed_y}});
- unsigned int dv1 = (Nx * x) / 2 + ((y + (x + 1) % 2) / 2) % (Nx / 2);
- unsigned int dv2 = ((Nx * (x + 1)) / 2 + ((y + x % 2) / 2) % (Nx / 2)) % nv;
+ unsigned int dv1 = (Nx * y) / 2 + ((x + (y + 1) % 2) / 2) % (Nx / 2);
+ unsigned int dv2 = ((Nx * (y + 1)) / 2 + ((x + y % 2) / 2) % (Nx / 2)) % nv;
- dual_edges.push_back({{dv1, dv2}, {0.5 + (double)y, 0.5 + (double)x}, {crossed_x, crossed_y}});
+ dual_edges.push_back({{dv1, dv2}, {0.5 + (double)x, 0.5 + (double)y}, {crossed_x, crossed_y}});
}
}