diff options
author | Jaron Kent-Dobias <jaron@kent-dobias.com> | 2019-04-19 13:31:16 -0400 |
---|---|---|
committer | Jaron Kent-Dobias <jaron@kent-dobias.com> | 2019-04-19 13:31:16 -0400 |
commit | 1cd41b27808da0fe558cfe31dfc370a71ea2dc50 (patch) | |
tree | 235983765d267a5b95af90f8c82431bcc72d1732 /lib | |
parent | ea4113e623170692a469f152752f9d583eecfedd (diff) | |
download | fuse_networks-1cd41b27808da0fe558cfe31dfc370a71ea2dc50.tar.gz fuse_networks-1cd41b27808da0fe558cfe31dfc370a71ea2dc50.tar.bz2 fuse_networks-1cd41b27808da0fe558cfe31dfc370a71ea2dc50.zip |
added support for rotating a lattice
Diffstat (limited to 'lib')
-rw-r--r-- | lib/include/graph.hpp | 1 | ||||
-rw-r--r-- | lib/src/graph.cpp | 39 |
2 files changed, 38 insertions, 2 deletions
diff --git a/lib/include/graph.hpp b/lib/include/graph.hpp index 032a4d1..1714dc2 100644 --- a/lib/include/graph.hpp +++ b/lib/include/graph.hpp @@ -42,5 +42,6 @@ class graph { graph(unsigned n, double a, std::mt19937& rng); void helper(unsigned n, std::mt19937& rng); + graph const rotate(); }; diff --git a/lib/src/graph.cpp b/lib/src/graph.cpp index 364f339..974d3b3 100644 --- a/lib/src/graph.cpp +++ b/lib/src/graph.cpp @@ -157,9 +157,8 @@ graph::graph(unsigned n, double a, std::mt19937& rng) { this->helper(n, rng); } -void graph::helper(unsigned n, std::mt19937& rng) { +void graph::helper(unsigned nv, std::mt19937& rng) { std::uniform_real_distribution<double> d(0.0, 1.0); - unsigned nv = n; vertices.resize(nv); // the coordinates of the lattice, from which a delaunay triangulation @@ -363,3 +362,39 @@ void graph::helper(unsigned n, std::mt19937& rng) { jcv_diagram_free(&diagram); } +graph::coordinate reverse(const graph::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) { + r = reverse(r); + } + } + + for (graph::edge &e : g2.edges) { + e.r = reverse(e.r); + e.crossings = {e.crossings[1], e.crossings[0]}; + } + + for (graph::vertex &v : g2.dual_vertices) { + v.r = reverse(v.r); + for (graph::coordinate &r : v.polygon) { + r = reverse(r); + } + } + + for (graph::edge &e : g2.dual_edges) { + e.r = reverse(e.r); + e.crossings = {e.crossings[1], e.crossings[0]}; + } + + g2.L = reverse(g2.L); + + return g2; +} + |