diff --git a/arbitrile.cpp b/arbitrile.cpp index 27f11cf2..e7bd7574 100644 --- a/arbitrile.cpp +++ b/arbitrile.cpp @@ -805,6 +805,12 @@ struct hrmap_arbi : hrmap { int shvid(cell *c) override { return id_of(c->master); } + + hyperpoint get_corner(cell *c, int cid, ld cf) override { + auto& sh = arb::current_or_slided().shapes[arb::id_of(c->master)]; + return normalize(C0 + (sh.vertices[gmod(cid, c->type)] - C0) * 3 / cf); + } + }; EX hrmap *new_map() { return new hrmap_arbi; } diff --git a/archimedean.cpp b/archimedean.cpp index 02038556..e34424bc 100644 --- a/archimedean.cpp +++ b/archimedean.cpp @@ -787,6 +787,28 @@ struct hrmap_archimedean : hrmap { if(ac.regular && id>=2 && id < 2*ac.N) id &= 1; return id; } + + hyperpoint get_corner(cell *c, int cid, ld cf) override { + auto &ac = arcm::current_or_fake(); + 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(DUAL) { + auto& t0 = ac.get_triangle(c->master, 2*cid-1); + return xspinpush0(-t0.first, t0.second * 3 / cf * (ac.real_faces == 0 ? 0.999 : 1)); + } + return C0; + } + }; EX hrmap *new_map() { return new hrmap_archimedean; } diff --git a/binary-tiling.cpp b/binary-tiling.cpp index ffd8e878..e887c49e 100644 --- a/binary-tiling.cpp +++ b/binary-tiling.cpp @@ -440,6 +440,14 @@ EX namespace bt { return 0; } + hyperpoint get_corner(cell *c, int cid, ld cf) override { + if(WDIM == 3) { + println(hlog, "get_corner_position called"); + return C0; + } + return mid_at_actual(bt::get_horopoint(bt::get_corner_horo_coordinates(c, cid)), 3/cf); + } + int updir_at(heptagon *h) { if(geometry != gBinaryTiling) return updir(); else if(type_of(h) == 6) return bd_down; diff --git a/cell.cpp b/cell.cpp index 38904865..827f7c5e 100644 --- a/cell.cpp +++ b/cell.cpp @@ -62,6 +62,7 @@ struct hrmap { virtual void find_cell_connection(cell *c, int d); virtual int shvid(cell *c) { return 0; } + virtual hyperpoint get_corner(cell *c, int cid, ld cf=3) { return C0; } }; /** hrmaps which are based on regular non-Euclidean 2D tilings, possibly quotient @@ -80,6 +81,7 @@ struct hrmap_standard : hrmap { double spacedist(cell *c, int i) override; void find_cell_connection(cell *c, int d) override; virtual int shvid(cell *c); + virtual hyperpoint get_corner(cell *c, int cid, ld cf) override; }; void clearfrom(heptagon*); diff --git a/geometry2.cpp b/geometry2.cpp index a8814d1d..0335a21b 100644 --- a/geometry2.cpp +++ b/geometry2.cpp @@ -520,39 +520,12 @@ EX hyperpoint randomPointIn(int t) { */ EX hyperpoint get_corner_position(cell *c, int cid, ld cf IS(3)) { + return currentmap->get_corner(c, cid, cf); + } + +hyperpoint hrmap_standard::get_corner(cell *c, int cid, ld cf) { #if CAP_GP if(GOLDBERG) return gp::get_corner_position(c, cid, cf); - if(UNTRUNCATED) { - cell *c1 = gp::get_mapped(c); - cellwalker cw(c1, cid*2); - if(!gp::untruncated_shift(c)) cw--; - hyperpoint h = UIU(nearcorner(c1, cw.spin)); - return mid_at_actual(h, 3/cf); - } - if(UNRECTIFIED) { - cell *c1 = gp::get_mapped(c); - hyperpoint h = UIU(nearcorner(c1, cid)); - return mid_at_actual(h, 3/cf); - } - if(WARPED) { - int sh = gp::untruncated_shift(c); - cell *c1 = gp::get_mapped(c); - if(sh == 2) { - cellwalker cw(c, cid); - hyperpoint h1 = UIU(tC0(currentmap->adj(c1, cid))); - cw--; - hyperpoint h2 = UIU(tC0(currentmap->adj(c1, cw.spin))); - hyperpoint h = mid(h1, h2); - return mid_at_actual(h, 3/cf); - } - else { - cellwalker cw(c1, cid*2); - if(!gp::untruncated_shift(c)) cw--; - hyperpoint h = UIU(nearcorner(c1, cw.spin)); - h = mid(h, C0); - return mid_at_actual(h, 3/cf); - } - } #endif #if CAP_IRR if(IRREGULAR) { @@ -560,41 +533,6 @@ EX hyperpoint get_corner_position(cell *c, int cid, ld cf IS(3)) { return mid_at_actual(vs.vertices[cid], 3/cf); } #endif - #if CAP_BT - if(kite::in()) return kite::get_corner(c, cid, cf); - if(bt::in()) { - if(WDIM == 3) { - println(hlog, "get_corner_position called"); - return C0; - } - return mid_at_actual(bt::get_horopoint(bt::get_corner_horo_coordinates(c, cid)), 3/cf); - } - #endif - #if CAP_ARCM - if(arcm::in()) { - auto &ac = arcm::current_or_fake(); - 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(DUAL) { - auto& t0 = ac.get_triangle(c->master, 2*cid-1); - return xspinpush0(-t0.first, t0.second * 3 / cf * (ac.real_faces == 0 ? 0.999 : 1)); - } - } - #endif - if(arb::in()) { - auto& sh = arb::current_or_slided().shapes[arb::id_of(c->master)]; - return normalize(C0 + (sh.vertices[gmod(cid, c->type)] - C0) * 3 / cf); - } if(PURE) { return ddspin(c,cid,M_PI/S7) * xpush0(cgi.hcrossf * 3 / cf); } @@ -674,7 +612,7 @@ EX hyperpoint nearcorner(cell *c, int i) { } if(kite::in()) { if(approx_nearcorner) - return kite::get_corner(c, i, 3) + kite::get_corner(c, i+1, 3) - C0; + return currentmap->get_corner(c, i, 3) + currentmap->get_corner(c, i+1, 3) - C0; else return calc_relative_matrix(c->cmove(i), c, C0) * C0; } diff --git a/goldberg.cpp b/goldberg.cpp index 24445e35..264ece58 100644 --- a/goldberg.cpp +++ b/goldberg.cpp @@ -1280,6 +1280,41 @@ EX namespace gp { int shvid(cell *c) override { return gp::get_plainshape_id(c); } + + hyperpoint get_corner(cell *c, int cid, ld cf) override { + if(UNTRUNCATED) { + cell *c1 = gp::get_mapped(c); + cellwalker cw(c1, cid*2); + if(!gp::untruncated_shift(c)) cw--; + hyperpoint h = UIU(nearcorner(c1, cw.spin)); + return mid_at_actual(h, 3/cf); + } + if(UNRECTIFIED) { + cell *c1 = gp::get_mapped(c); + hyperpoint h = UIU(nearcorner(c1, cid)); + return mid_at_actual(h, 3/cf); + } + if(WARPED) { + int sh = gp::untruncated_shift(c); + cell *c1 = gp::get_mapped(c); + if(sh == 2) { + cellwalker cw(c, cid); + hyperpoint h1 = UIU(tC0(currentmap->adj(c1, cid))); + cw--; + hyperpoint h2 = UIU(tC0(currentmap->adj(c1, cw.spin))); + hyperpoint h = mid(h1, h2); + return mid_at_actual(h, 3/cf); + } + else { + cellwalker cw(c1, cid*2); + if(!gp::untruncated_shift(c)) cw--; + hyperpoint h = UIU(nearcorner(c1, cw.spin)); + h = mid(h, C0); + return mid_at_actual(h, 3/cf); + } + } + return C0; + } }; EX hrmap* new_inverse() { return new hrmap_inverse; } diff --git a/kite.cpp b/kite.cpp index f9beefac..215b6181 100644 --- a/kite.cpp +++ b/kite.cpp @@ -61,23 +61,6 @@ const ld kite_center = up; EX pshape getshape(heptagon *h) { return pshape(h->s); } -EX hyperpoint get_corner(cell *c, int d, ld cf) { - bool kite = getshape(c->master) == pKite; - int t = kite ? 1 : -1; - ld shf = kite ? kite_center : dart_center; - - ld mul = 3/cf; - - switch(d & 3) { - case 0: return mhpxy(-mul, (shf)*mul); - case 1: return mhpxy(0, (shf-down)*mul); - case 2: return mhpxy(+mul, shf*mul); - case 3: return mhpxy(0, (shf + t*up)*mul); - } - - return C0; /* unreachable! */ - } - EX pair>, vector>> make_walls() { vector> kv; @@ -152,6 +135,23 @@ struct hrmap_kite : hrmap { kite::find_cell_connection(c, d); } + hyperpoint get_corner(cell *c, int cid, ld cf) override { + bool kite = getshape(c->master) == pKite; + int t = kite ? 1 : -1; + ld shf = kite ? kite_center : dart_center; + + ld mul = 3/cf; + + switch(cid & 3) { + case 0: return mhpxy(-mul, (shf)*mul); + case 1: return mhpxy(0, (shf-down)*mul); + case 2: return mhpxy(+mul, shf*mul); + case 3: return mhpxy(0, (shf + t*up)*mul); + } + + return C0; /* unreachable! */ + } + int shvid(cell *c) override { return kite::getshape(c->master); }