From 5ab7249afd8b4f07d424f3b6b96e1c0a2e569ce2 Mon Sep 17 00:00:00 2001 From: Zeno Rogue Date: Thu, 9 May 2019 17:00:05 +0200 Subject: [PATCH] horopoint cleanup in 2D --- binary-tiling.cpp | 24 ++++++++++ floorshapes.cpp | 116 +++++++++++++++++++++------------------------- geometry2.cpp | 35 ++++---------- graph.cpp | 4 +- hyper.h | 6 +-- polygons.cpp | 6 +-- 6 files changed, 94 insertions(+), 97 deletions(-) diff --git a/binary-tiling.cpp b/binary-tiling.cpp index 9094615d..8d19e194 100644 --- a/binary-tiling.cpp +++ b/binary-tiling.cpp @@ -793,6 +793,30 @@ void virtualRebaseSimple(heptagon*& base, transmatrix& at) { } #endif +hyperpoint get_horopoint(ld y, ld x) { + return xpush(-y) * binary::parabolic(x) * C0; + } + +hyperpoint get_horopoint(hyperpoint h) { + return get_horopoint(h[0], h[1]); + } + +hyperpoint get_corner_horo_coordinates(cell *c, int i) { + ld yx = log(2) / 2; + ld yy = yx; + ld xx = 1 / sqrt(2)/2; + switch(gmod(i, c->type)) { + case 0: return point2(-yy, xx); + case 1: return point2(yy, 2*xx); + case 2: return point2(yy, xx); + case 3: return point2(yy, -xx); + case 4: return point2(yy, -2*xx); + case 5: return point2(-yy, -xx); + case 6: return point2(-yy, 0); + default: return point2(0, 0); + } + } + } } diff --git a/floorshapes.cpp b/floorshapes.cpp index d9f868e3..86e6685b 100644 --- a/floorshapes.cpp +++ b/floorshapes.cpp @@ -196,28 +196,6 @@ void bshape2(hpcshape& sh, PPR prio, int shapeid, matrixlist& m) { hpcpush(hpc[last->s]); } -#if CAP_BT -void horopoint(ld y, ld x) { - hpcpush(get_horopoint(y, x)); - } - -void horopoint(ld y, ld x, cell &fc, int c) { - hpcpush(iddspin(&fc, c) * get_horopoint(y, x)); - } - -void horoline(ld y, ld x1, ld x2) { - if(DIM == 3) - horopoint(y, x1), horopoint(y, x2); - else for(int a=0; a<=16; a++) - horopoint(y, x1 + (x2-x1) * a / 16.); - } - -void horoline(ld y, ld x1, ld x2, cell &fc, int c) { - for(int a=0; a<=16; a++) - horopoint(y, x1 + (x2-x1) * a / 16., fc, c); - } -#endif - void bshape_regular(floorshape &fsh, int id, int sides, int shift, ld size) { fsh.b.resize(2); @@ -225,32 +203,41 @@ void bshape_regular(floorshape &fsh, int id, int sides, int shift, ld size) { #if CAP_BT if(binarytiling) { - bshape(fsh.b[id], fsh.prio); - - ld yx = size * log(2) / 2; - ld yy = yx; - ld xx = size / sqrt(2)/2; - horoline(-yx, -xx, xx); horoline(yx, xx*2, -xx*2); horopoint(-yx, -xx); - - bshape(fsh.shadow[id], fsh.prio); - horoline(-yx*SHADMUL, -xx*SHADMUL, xx*SHADMUL); horoline(yx*SHADMUL, xx*SHADMUL*2, -xx*SHADMUL*2); horopoint(-yx*SHADMUL, -xx*SHADMUL); cell fc; fc.type = 6+id; - - for(int k=0; ks]); + } + + for(int k=0; k cors; - for(int i=0; itype; i++) cors.push_back(get_corner_position(c, i, 3)); - cors.push_back(cors[0]); for(int t=0; ttype; t++) for(int y=0; ytype == 7) - neis[5] = get_horopoint(-yy*2, -.5), - neis[6] = get_horopoint(-yy*2, +.5); + neis[5] = binary::get_horopoint(-yy*2, -.5), + neis[6] = binary::get_horopoint(-yy*2, +.5); else - neis[5] = get_horopoint(-yy*2, 0); + neis[5] = binary::get_horopoint(-yy*2, 0); return neis[i]; } #endif diff --git a/graph.cpp b/graph.cpp index e400eeac..2668f5e5 100644 --- a/graph.cpp +++ b/graph.cpp @@ -5587,11 +5587,11 @@ void drawcell(cell *c, transmatrix V, int spinv, bool mirrored) { ld yx = log(2) / 2; ld yy = yx; ld xx = 1 / sqrt(2)/2; - queueline(V * get_horopoint(-yy, xx), V * get_horopoint(yy, 2*xx), gridcolor(c, c->move(binary::bd_right)), prec); + queueline(V * binary::get_horopoint(-yy, xx), V * binary::get_horopoint(yy, 2*xx), gridcolor(c, c->move(binary::bd_right)), prec); auto horizontal = [&] (ld y, ld x1, ld x2, int steps, int dir) { if(vid.linequality > 0) steps <<= vid.linequality; if(vid.linequality < 0) steps >>= -vid.linequality; - for(int i=0; i<=steps; i++) curvepoint(V * get_horopoint(y, x1 + (x2-x1) * i / steps)); + for(int i=0; i<=steps; i++) curvepoint(V * binary::get_horopoint(y, x1 + (x2-x1) * i / steps)); queuecurve(gridcolor(c, c->move(dir)), 0, PPR::LINE); }; horizontal(yy, 2*xx, xx, 4, binary::bd_up_right); diff --git a/hyper.h b/hyper.h index eff633b7..84660ca1 100644 --- a/hyper.h +++ b/hyper.h @@ -4387,9 +4387,6 @@ bool saved_tortoise_on(cell *c); #define PRING(i) for(double i=0; i<=S84+1e-6; i+= pow(.5, vid.linequality)) #define REVPRING(i) for(double i=S84; i>=-1e-6; i-=pow(.5, vid.linequality)) #if CAP_BT -void horopoint(ld y, ld x); -hyperpoint get_horopoint(ld y, ld x); -hyperpoint get_horopoint3(ld y, ld x, ld z); namespace binary { transmatrix parabolic(ld u); @@ -4397,6 +4394,9 @@ namespace binary { extern ld btrange, btrange_cosh; hrmap *new_map(); hrmap *new_alt_map(heptagon *o); + hyperpoint get_horopoint(ld y, ld x); + hyperpoint get_horopoint3(ld y, ld x, ld z); + hyperpoint get_horopoint(hyperpoint h); } #endif diff --git a/polygons.cpp b/polygons.cpp index d3ea6a78..8e851f1e 100644 --- a/polygons.cpp +++ b/polygons.cpp @@ -2112,9 +2112,9 @@ void procedural_shapes() { else if(binarytiling) { for(int i=0; i<2; i++) { bshape(shWall[i], PPR::WALL); - horopoint(log(2)/8, .1); - horopoint(log(2)/8, -.1); - horopoint(-log(2)/8, 0); + hpcpush(binary::get_horopoint(log(2)/8, .1)); + hpcpush(binary::get_horopoint(log(2)/8, -.1)); + hpcpush(binary::get_horopoint(-log(2)/8, 0)); } } #endif