diff options
author | Jaron Kent-Dobias <jaron@kent-dobias.com> | 2019-01-24 18:55:15 -0500 |
---|---|---|
committer | Jaron Kent-Dobias <jaron@kent-dobias.com> | 2019-01-24 18:55:15 -0500 |
commit | 2b9a37884b27e272c48c3c44e4ddd0d091b7f16d (patch) | |
tree | 344b8e70a2632bb97c2b55cab408a9bb4bb42e90 | |
parent | 4312dd98eb34b36cba2d654704719a6edb4497b9 (diff) | |
download | fuse_networks-2b9a37884b27e272c48c3c44e4ddd0d091b7f16d.tar.gz fuse_networks-2b9a37884b27e272c48c3c44e4ddd0d091b7f16d.tar.bz2 fuse_networks-2b9a37884b27e272c48c3c44e4ddd0d091b7f16d.zip |
made square graph construction sane
-rw-r--r-- | lib/src/graph.cpp | 36 |
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}}); } } |