diff --git a/conformal.cpp b/conformal.cpp index c687a7f8..a0179dc8 100644 --- a/conformal.cpp +++ b/conformal.cpp @@ -400,6 +400,8 @@ namespace conformal { osin = sin(model_orientation * degree); model_straight = (ocos > 1 - 1e-9); if(conformal::on) conformal::apply(); + + band_shift = 0; } ld measureLength() { diff --git a/hyper.h b/hyper.h index 8c7bff02..2e89b3d5 100644 --- a/hyper.h +++ b/hyper.h @@ -2625,6 +2625,7 @@ struct drawqueueitem { }; struct dqi_poly : drawqueueitem { + ld band_shift; transmatrix V; const vector *tab; int offset, cnt; @@ -2640,6 +2641,7 @@ struct dqi_poly : drawqueueitem { }; struct dqi_line : drawqueueitem { + ld band_shift; hyperpoint H1, H2; int prf; double width; @@ -4328,5 +4330,15 @@ string parser_help(); static const ld degree = M_PI / 180; void show_color_dialog(); + +extern ld band_shift; + +void fix_the_band(transmatrix& T); + +struct bandfixer { + dynamicval bw; + bandfixer(transmatrix& T) : bw(band_shift, band_shift) { fix_the_band(T); } + }; + } diff --git a/hypgraph.cpp b/hypgraph.cpp index 837311a5..0b2ea0b9 100644 --- a/hypgraph.cpp +++ b/hypgraph.cpp @@ -163,7 +163,7 @@ template void makeband(hyperpoint H, hyperpoint& ret, const T& f) { ld x, y, yf, zf=0; y = asin_auto(H[1]); - x = asin_auto_clamp(H[0] / cos_auto(y)); + x = asin_auto_clamp(H[0] / cos_auto(y)) + band_shift; if(sphere) { if(H[2] < 0 && x > 0) x = M_PI - x; else if(H[2] < 0 && x <= 0) x = -M_PI - x; @@ -774,7 +774,7 @@ void drawrec(const heptspin& hs, hstate s, const transmatrix& V, int reclev) { bool draw = c->pathdist < PINFD; - if(cells_drawn > vid.cells_drawn_limit || reclev >= 100 || std::isinf(V[2][2]) || std::isnan(V[2][2])) + if(cells_drawn > vid.cells_drawn_limit || reclev >= 10000 || std::isinf(V[2][2]) || std::isnan(V[2][2]) || V[2][2] > 1e8) draw = false; else if(vid.use_smart_range) { draw = reclev < 2 ? true : in_smart_range(V); @@ -817,7 +817,9 @@ void drawrec(const heptspin& hs, hstate s, const transmatrix& V, int reclev) { hstate s2 = transition(s, d); if(s2 == hsError) continue; heptspin hs2 = hs + d + wstep; - drawrec(hs2, s2, V * heptmove[d], reclev+1); + transmatrix Vd = V * heptmove[d]; + bandfixer bf(Vd); + drawrec(hs2, s2, Vd, reclev+1); } } @@ -1345,4 +1347,21 @@ void draw_boundary(int w) { */ } +ld band_shift = 0; +void fix_the_band(transmatrix& T) { + if((models[pmodel].flags & mf::quasiband) && T[2][2] > 1e6) { + hyperpoint H = tC0(T); + find_zlev(H); + conformal::apply_orientation(H[0], H[1]); + + ld y = asin_auto(H[1]); + ld x = asin_auto_clamp(H[0] / cos_auto(y)); + band_shift += x; + // printf("fixing with shift = %lf\n", x); + T = xpush(-x) * T; + fixmatrix(T); + // todo orientation + } + } + } diff --git a/polygons.cpp b/polygons.cpp index df1e5fe3..0cf1c7fc 100644 --- a/polygons.cpp +++ b/polygons.cpp @@ -834,6 +834,7 @@ ld get_width(dqi_poly* p) { void dqi_poly::draw() { + dynamicval bs(hr::band_shift, band_shift); if(!hyperbolic && among(pmodel, mdPolygonal, mdPolynomial)) { bool any = false; for(int i=0; i& t, color_t fillcol, color_t linecol, i prettylinesub(t[i], t[(i+1)%3], lev); dqi_poly ptd; ptd.V = Id; + ptd.band_shift = band_shift; ptd.tab = &prettylinepoints; ptd.offset = 0; ptd.cnt = isize(prettylinepoints); @@ -1214,6 +1217,7 @@ void queuereset(eModel m, PPR prio) { void dqi_line::draw() { dynamicval d(vid.linewidth, width); + dynamicval bs(hr::band_shift, band_shift); prettyline(H1, H2, color, prf, 0); } @@ -2639,6 +2643,7 @@ dqi_poly& queuepolyat(const transmatrix& V, const hpcshape& h, color_t col, PPR auto& ptd = queuea (prio); ptd.V = V; + ptd.band_shift = band_shift; ptd.offset = h.s; ptd.cnt = h.e-h.s; ptd.tab = &ourshape; @@ -2674,6 +2679,7 @@ dqi_poly& queuetable(const transmatrix& V, const vector& f, int cnt, c auto& ptd = queuea (prio); ptd.V = V; + ptd.band_shift = band_shift; ptd.tab = &f; ptd.offset = 0; ptd.cnt = cnt; @@ -2714,6 +2720,7 @@ dqi_line& queueline(const hyperpoint& H1, const hyperpoint& H2, color_t col, int ptd.H1 = H1; ptd.H2 = H2; + ptd.band_shift = band_shift; ptd.prf = prf; ptd.width = vid.linewidth; ptd.color = (darkened(col >> 8) << 8) + (col & 0xFF);