From 020d9679bddeada2bf4b3a106ee31acb9f5a0bd4 Mon Sep 17 00:00:00 2001 From: Zeno Rogue Date: Wed, 29 Aug 2018 04:28:34 +0200 Subject: [PATCH] bitruncated Archimedean tilings --- archimedean.cpp | 27 +++++++++++++++++++++- floorshapes.cpp | 6 +++-- geometry2.cpp | 59 +++++++++++++++++++++++++++++++++++++------------ graph.cpp | 10 +++++++-- pattern2.cpp | 12 +++++++--- 5 files changed, 92 insertions(+), 22 deletions(-) diff --git a/archimedean.cpp b/archimedean.cpp index 85a5b100..a60823e7 100644 --- a/archimedean.cpp +++ b/archimedean.cpp @@ -61,6 +61,7 @@ struct archimedean_tiling { pair& get_adj(const pair& p, int delta = 0); int support_threecolor(); + int support_threecolor_bitruncated(); int support_football(); bool support_chessboard(); void regroup(); @@ -521,6 +522,14 @@ heptagon *build_child(heptspin p, pair adj) { else h->fieldval = -100; h->fiftyval = isize(archimedean_gmatrix); + if(p.at->s == hsOrigin) + h->rval1 = 1 + (p.spin % 2); + else { + if(p.spin % 2 == 0) + h->rval1 = p.at->move(0)->rval1; + else + h->rval1 = 3 - p.at->move(0)->rval1 - p.at->rval1; + } heptspin hs(h, 0); return h; } @@ -809,6 +818,10 @@ int archimedean_tiling::support_threecolor() { return 2; } +int archimedean_tiling::support_threecolor_bitruncated() { + return N % 2 == 0 ? 2 : 0; + } + int archimedean_tiling::support_football() { return have_ph ? 1 : @@ -821,7 +834,11 @@ bool archimedean_tiling::support_chessboard() { } bool pseudohept(int id) { - return current.flags[id] & arcm::sfPH; + if(PURE) + return current.flags[id] & arcm::sfPH; + if(BITRUNCATED) + return id < current.N * 2; + return false; } bool chessvalue(cell *c) { @@ -1088,6 +1105,14 @@ void show() { restart_game(); }); } + + if(archimedean) { + dialog::addSelItem(XLAT("variations"), gp::operation_name(), 'v'); + dialog::add_action([] () { + set_variation(PURE ? eVariation::bitruncated : eVariation::pure); + start_game(); + }); + } } dialog::addHelp(); diff --git a/floorshapes.cpp b/floorshapes.cpp index 77296c4c..f35bbf6b 100644 --- a/floorshapes.cpp +++ b/floorshapes.cpp @@ -497,10 +497,12 @@ void generate_floorshapes() { model.master = &master; arcm::parent_index_of(&master) = 0; auto &ac = arcm::current; - for(int i=0; i<2*ac.N + (PURE ? 0 : 2); i++) { + for(int i=0; i<2*ac.N + 2; i++) { arcm::id_of(&master) = i; model.type = isize(ac.triangles[i]); - if(geosupport_football() == 2) + if(BITRUNCATED) + generate_floorshapes_for(i, &model, !arcm::pseudohept(i), arcm::pseudohept(i) ? 0 : 1^(i&1)); + else if(geosupport_football() == 2) generate_floorshapes_for(i, &model, !arcm::pseudohept(i), i >= 4 ? 1 : 0); else generate_floorshapes_for(i, &model, 0, 0); diff --git a/geometry2.cpp b/geometry2.cpp index 53fdf344..b914634a 100644 --- a/geometry2.cpp +++ b/geometry2.cpp @@ -396,9 +396,18 @@ hyperpoint get_corner_position(cell *c, int cid, ld cf) { } if(archimedean) { auto &ac = arcm::current; - if(arcm::id_of(c->master) >= ac.N*2) return C0; - auto& t = ac.get_triangle(c->master, cid-1); - return xspinpush0(-t.first, t.second * 3 / cf * (ac.real_faces == 0 ? 0.999 : 1)); + if(PURE) { + if(arcm::id_of(c->master) >= ac.N*2) return C0; + auto& t = ac.get_triangle(c->master, cid-1); + return xspinpush0(-t.first, t.second * 3 / cf * (ac.real_faces == 0 ? 0.999 : 1)); + } + if(BITRUNCATED) { + auto& t0 = ac.get_triangle(c->master, cid-1); + auto& t1 = ac.get_triangle(c->master, cid); + hyperpoint h0 = xspinpush0(-t0.first, t0.second * 3 / cf * (ac.real_faces == 0 ? 0.999 : 1)); + hyperpoint h1 = xspinpush0(-t1.first, t1.second * 3 / cf * (ac.real_faces == 0 ? 0.999 : 1)); + return mid3(C0, h0, h1); + } } if(PURE) { return ddspin(c,cid,M_PI/S7) * xpush0(hcrossf * 3 / cf); @@ -426,11 +435,18 @@ hyperpoint nearcorner(cell *c, int i) { return mid_at(C0, nc, .94); } if(archimedean) { - auto &ac = arcm::current; - auto& t = ac.get_triangle(c->master, i-1); - int id = arcm::id_of(c->master); - int id1 = ac.get_adj(ac.get_adj(c->master, i-1), -2).first; - return xspinpush0(-t.first - M_PI / c->type, ac.inradius[id/2] + ac.inradius[id1/2] + (ac.real_faces == 0 ? 2 * M_PI / (ac.N == 2 ? 2.1 : ac.N) : 0)); + if(PURE) { + auto &ac = arcm::current; + auto& t = ac.get_triangle(c->master, i-1); + int id = arcm::id_of(c->master); + int id1 = ac.get_adj(ac.get_adj(c->master, i-1), -2).first; + return xspinpush0(-t.first - M_PI / c->type, ac.inradius[id/2] + ac.inradius[id1/2] + (ac.real_faces == 0 ? 2 * M_PI / (ac.N == 2 ? 2.1 : ac.N) : 0)); + } + if(BITRUNCATED) { + auto &ac = arcm::current; + auto& t = ac.get_triangle(c->master, i); + return xspinpush0(-t.first, t.second); + } } if(binarytiling) { ld yx = log(2) / 2; @@ -481,12 +497,27 @@ hyperpoint farcorner(cell *c, int i, int which) { if(binarytiling) return nearcorner(c, (i+which) % c->type); // lazy if(archimedean) { - auto &ac = arcm::current; - auto& t = ac.get_triangle(c->master, i-1); - int id = arcm::id_of(c->master); - auto id1 = ac.get_adj(ac.get_adj(c->master, i-1), -2).first; - int n1 = isize(ac.adjacent[id1]); - return spin(-t.first - M_PI / c->type) * xpush(ac.inradius[id/2] + ac.inradius[id1/2]) * xspinpush0(M_PI + M_PI/n1*(which?3:-3), ac.circumradius[id1/2]); + if(PURE) { + auto &ac = arcm::current; + auto& t = ac.get_triangle(c->master, i-1); + int id = arcm::id_of(c->master); + auto id1 = ac.get_adj(ac.get_adj(c->master, i-1), -2).first; + int n1 = isize(ac.adjacent[id1]); + return spin(-t.first - M_PI / c->type) * xpush(ac.inradius[id/2] + ac.inradius[id1/2]) * xspinpush0(M_PI + M_PI/n1*(which?3:-3), ac.circumradius[id1/2]); + } + if(BITRUNCATED) { + auto &ac = arcm::current; + auto adj = ac.get_adj(c->master, i); + heptagon h; cell cx; cx.master = &h; + arcm::id_of(&h) = adj.first; + arcm::parent_index_of(&h) = adj.second; + + auto& t1 = arcm::current.get_triangle(c->master, i); + + auto& t2 = arcm::current.get_triangle(adj); + + return spin(-t1.first) * xpush(t1.second) * spin(M_PI + t2.first) * get_corner_position(&cx, which ? -1 : 2); + } } return cellrelmatrix(c, i) * get_corner_position(c->move(i), (cellwalker(c, i) + wstep + (which?-1:2)).spin); diff --git a/graph.cpp b/graph.cpp index c1ed659d..ecc0c3bf 100644 --- a/graph.cpp +++ b/graph.cpp @@ -236,8 +236,14 @@ void drawLightning(const transmatrix& V) { ld displayspin(cell *c, int d) { if(archimedean) { - auto& t1 = arcm::current.get_triangle(c->master, d-1); - return -(t1.first + M_PI / c->type); + if(PURE) { + auto& t1 = arcm::current.get_triangle(c->master, d-1); + return -(t1.first + M_PI / c->type); + } + else { /* BITRUNCATED */ + auto& t1 = arcm::current.get_triangle(c->master, d); + return -t1.first; + } } else if(IRREGULAR) { auto id = irr::cellindex[c]; diff --git a/pattern2.cpp b/pattern2.cpp index ebfad201..7d059165 100644 --- a/pattern2.cpp +++ b/pattern2.cpp @@ -1065,11 +1065,13 @@ namespace patterns { } bool geosupport_chessboard() { - return archimedean ? arcm::current.support_chessboard() : (VALENCE % 2 == 0); + return (archimedean && PURE) ? arcm::current.support_chessboard() : (VALENCE % 2 == 0); } int geosupport_threecolor() { if(IRREGULAR) return 0; + if(archimedean && PURE) return arcm::current.support_threecolor(); + if(archimedean && BITRUNCATED) return arcm::current.support_threecolor_bitruncated(); if(BITRUNCATED && S3 == 3) { if(S7 % 2) return 1; return 2; @@ -1078,7 +1080,6 @@ int geosupport_threecolor() { return 2; if(a46 && PURE) return 1; - if(archimedean) return arcm::current.support_threecolor(); return 0; } @@ -1102,7 +1103,12 @@ int geosupport_football() { } int pattern_threecolor(cell *c) { - if(archimedean) return arcm::threecolor(arcm::id_of(c->master)); + if(archimedean) { + if(PURE) + return arcm::threecolor(arcm::id_of(c->master)); + else /* if(BITRUNCATED) */ + return c->master->rval1; + } if(IRREGULAR || binarytiling) return !pseudohept(c); if(S3 == 3 && !(S7&1) && gp_threecolor() == 1 && c->master->c7 != c) { auto li = gp::get_local_info(c);