From d8da9639d07ebd4026b78ddc4cfabc67f81d9d34 Mon Sep 17 00:00:00 2001 From: Zeno Rogue Date: Sat, 8 Oct 2022 01:53:02 +0200 Subject: [PATCH] tes:: split get_adj into two functions, one with connection specified (inlcuding mirror), and one not --- arbitrile.cpp | 26 ++++++++++++++++---------- floorshapes.cpp | 6 +++--- rogueviz/balloonsim.cpp | 5 ++++- rulegen.cpp | 4 ++-- 4 files changed, 25 insertions(+), 16 deletions(-) diff --git a/arbitrile.cpp b/arbitrile.cpp index bcea70d6..a910c02c 100644 --- a/arbitrile.cpp +++ b/arbitrile.cpp @@ -1255,7 +1255,7 @@ void connection_debugger() { dialog::add_action([k, last, con] { if(euclid) cgflags |= qAFFINE; - debug_polys.emplace_back(last.first * get_adj(debugged, last.second, k, -1, -1), con.sid); + debug_polys.emplace_back(last.first * get_adj(debugged, last.second, k), con.sid); if(euclid) cgflags &= ~qAFFINE; }); @@ -1319,17 +1319,13 @@ EX bool apeirogon_consistent_coloring = true; EX bool apeirogon_hide_grid_edges = true; EX bool apeirogon_simplified_display = false; -EX transmatrix get_adj(arbi_tiling& c, int t, int dl, int t1, int xdl) { +/** get the adj matrix corresponding to the connection of (t,dl) to connection_t{t1, xdl, xmirror} */ +EX transmatrix get_adj(arbi_tiling& c, int t, int dl, int t1, int xdl, bool xmirror) { auto& sh = c.shapes[t]; int dr = gmod(dl+1, sh.size()); - auto& co = sh.connections[dl]; - if(xdl == -1) xdl = co.eid; - - if(t1 == -1) t1 = co.sid; - auto& xsh = c.shapes[t1]; int xdr = gmod(xdl+1, xsh.size()); @@ -1359,10 +1355,10 @@ EX transmatrix get_adj(arbi_tiling& c, int t, int dl, int t1, int xdl) { Res = Res * Tsca; } - if(co.mirror) Res = Res * MirrorX; + if(xmirror) Res = Res * MirrorX; Res = Res * spintox(xrm*xvl) * xrm; - if(co.mirror) swap(vl, vr); + if(xmirror) swap(vl, vr); if(hdist(vl, Res*xvr) + hdist(vr, Res*xvl) > .1 && !c.is_combinatorial) { println(hlog, "s1 = ", kz(spintox(rm*vr)), " s2 = ", kz(rspintox(xrm*xvr))); @@ -1374,6 +1370,13 @@ EX transmatrix get_adj(arbi_tiling& c, int t, int dl, int t1, int xdl) { return Res; } +/** get the adj matrix corresponding to the connection of (t,dl) -- note: it may be incorrect for rotated/symmetric connections */ +EX transmatrix get_adj(arbi_tiling& c, int t, int dl) { + auto& sh = c.shapes[t]; + auto& co = sh.connections[dl]; + return get_adj(c, t, dl, co.sid, co.eid, co.mirror); + } + struct hrmap_arbi : hrmap { heptagon *origin; heptagon *getOrigin() override { return origin; } @@ -1415,7 +1418,10 @@ struct hrmap_arbi : hrmap { void verify() override { } transmatrix adj(heptagon *h, int dl) override { - return get_adj(current_or_slided(), id_of(h), dl, -1, h->c.move(dl) ? h->c.spin(dl) : -1); + if(h->c.move(dl)) + return get_adj(current_or_slided(), id_of(h), dl, id_of(h->c.move(dl)), h->c.spin(dl), h->c.mirror(dl)); + else + return get_adj(current_or_slided(), id_of(h), dl); } heptagon *create_step(heptagon *h, int d) override { diff --git a/floorshapes.cpp b/floorshapes.cpp index e2b5e847..6806141c 100644 --- a/floorshapes.cpp +++ b/floorshapes.cpp @@ -505,8 +505,8 @@ void geometry_information::generate_floorshapes_for(int id, cell *c, int siid, i hyperpoint next = actual[jmaster); auto &ac = arb::current_or_slided(); auto& sh = ac.shapes[id]; - hpcpush(arb::get_adj(arb::current_or_slided(), id, cor-2, id, cor-1) * starting_point); + hpcpush(arb::get_adj(arb::current_or_slided(), id, cor-2, id, cor-1, false) * starting_point); finish_apeirogon(sh.vertices.back()); } } diff --git a/rogueviz/balloonsim.cpp b/rogueviz/balloonsim.cpp index e2848f41..0ed46c46 100644 --- a/rogueviz/balloonsim.cpp +++ b/rogueviz/balloonsim.cpp @@ -464,7 +464,10 @@ struct hrmap_arbi_full : hrmap { } transmatrix adj(heptagon *h, int dl) override { - return arb::get_adj(arb::current_or_slided(), arb::id_of(h), dl, h->c.move(dl) ? arb::id_of(h->c.move(dl)) : -1, h->c.move(dl) ? h->c.spin(dl) : -1); + if(h->c.move(dl)) + return arb::get_adj(arb::current_or_slided(), arb::id_of(h), dl, arb::id_of(h->c.move(dl)), h->c.spin(dl), h->c.mirror(dl)); + else + return arb::get_adj(arb::current_or_slided(), arb::id_of(h), dl); } ld spin_angle(cell *c, int d) override { return SPIN_NOT_AVAILABLE; } diff --git a/rulegen.cpp b/rulegen.cpp index 0f8d1364..028e2180 100644 --- a/rulegen.cpp +++ b/rulegen.cpp @@ -2302,7 +2302,7 @@ struct hrmap_rulegen : hrmap { transmatrix adj(heptagon *h, int dir) override { if(h->fieldval == -1) - return arb::get_adj(arb::current_or_slided(), h->zebraval, dir, -1, -1); + return arb::get_adj(arb::current_or_slided(), h->zebraval, dir); int s = h->fieldval; int dir0 = get_arb_dir(s, dir); @@ -2316,7 +2316,7 @@ struct hrmap_rulegen : hrmap { sid1 = treestates[s1].sid; } - return arb::get_adj(arb::current_or_slided(), treestates[s].sid, dir0, sid1, dir1); + return arb::get_adj(arb::current_or_slided(), treestates[s].sid, dir0, sid1, dir1, false); } int shvid(cell *c) override {