fixed the binary tiling to use correct straight lines on the vertical edges; also grid lines now work correctly

This commit is contained in:
Zeno Rogue 2022-12-15 09:58:47 +01:00
parent f9552eb74e
commit 62ffefc0cc
3 changed files with 39 additions and 39 deletions

View File

@ -1027,7 +1027,7 @@ EX int celldistance3(heptagon *c1, heptagon *c2) {
EX int celldistance3(cell *c1, cell *c2) { return celldistance3(c1->master, c2->master); } EX int celldistance3(cell *c1, cell *c2) { return celldistance3(c1->master, c2->master); }
EX hyperpoint get_horopoint(ld y, ld x) { EX hyperpoint get_horopoint(ld y, ld x) {
return xpush(-y) * bt::parabolic(x*2) * C0; return bt::parabolic(x*2) * xpush(-y) * C0;
} }
EX hyperpoint get_horopoint(hyperpoint h) { EX hyperpoint get_horopoint(hyperpoint h) {
@ -1035,17 +1035,16 @@ EX hyperpoint get_horopoint(hyperpoint h) {
} }
EX hyperpoint get_corner_horo_coordinates(cell *c, int i) { EX hyperpoint get_corner_horo_coordinates(cell *c, int i) {
ld yx = log(2) / 2; ld yy = log(2) / 2;
ld yy = yx; ld xx = 1 / 2.;
ld xx = 1 / sqrt(2)/2;
switch(geometry) { switch(geometry) {
case gBinaryTiling: case gBinaryTiling:
switch(gmod(i, c->type)) { switch(gmod(i, c->type)) {
case 0: return point2(-yy, xx); case 0: return point2(-yy, xx);
case 1: return point2(yy, 2*xx); case 1: return point2(yy, xx);
case 2: return point2(yy, xx); case 2: return point2(yy, xx/2);
case 3: return point2(yy, -xx); case 3: return point2(yy, -xx/2);
case 4: return point2(yy, -2*xx); case 4: return point2(yy, -xx);
case 5: return point2(-yy, -xx); case 5: return point2(-yy, -xx);
case 6: return point2(-yy, 0); case 6: return point2(-yy, 0);
default: return point2(0, 0); default: return point2(0, 0);
@ -1053,9 +1052,9 @@ EX hyperpoint get_corner_horo_coordinates(cell *c, int i) {
case gBinary4: case gBinary4:
switch(gmod(i, c->type)) { switch(gmod(i, c->type)) {
case 0: return point2(yy, -2*xx); case 0: return point2(yy, -xx);
case 1: return point2(yy, +0*xx); case 1: return point2(yy, +0*xx);
case 2: return point2(yy, +2*xx); case 2: return point2(yy, +xx);
case 3: return point2(-yy, xx); case 3: return point2(-yy, xx);
case 4: return point2(-yy, -xx); case 4: return point2(-yy, -xx);
default: return point2(0, 0); default: return point2(0, 0);
@ -1063,12 +1062,11 @@ EX hyperpoint get_corner_horo_coordinates(cell *c, int i) {
case gTernary: case gTernary:
yy = log(3) / 2; yy = log(3) / 2;
xx = 1 / sqrt(3) / 2;
switch(gmod(i, c->type)) { switch(gmod(i, c->type)) {
case 0: return point2(yy, -3*xx); case 0: return point2(yy, -xx);
case 1: return point2(yy, -1*xx); case 1: return point2(yy, -xx/3);
case 2: return point2(yy, +1*xx); case 2: return point2(yy, +xx/3);
case 3: return point2(yy, +3*xx); case 3: return point2(yy, +xx);
case 4: return point2(-yy, xx); case 4: return point2(-yy, xx);
case 5: return point2(-yy, -xx); case 5: return point2(-yy, -xx);
default: return point2(0, 0); default: return point2(0, 0);

View File

@ -905,20 +905,22 @@ void celldrawer::draw_grid() {
} }
#endif #endif
#if CAP_BT #if CAP_BT
else if(bt::in() && WDIM == 2 && geometry != gTernary) { else if(bt::in() && WDIM == 2) {
ld yx = log(2) / 2; for(int t=0; t<c->type; t++) {
ld yy = yx; auto h0 = bt::get_corner_horo_coordinates(c, t);
ld xx = 1 / sqrt(2)/2; auto h1 = bt::get_corner_horo_coordinates(c, t+1);
queueline(V * bt::get_horopoint(-yy, xx), V * bt::get_horopoint(yy, 2*xx), gridcolor(c, c->move(bt::bd_right)), prec); int steps = 12 * abs(h0[1] - h1[1]);
auto horizontal = [&] (ld y, ld x1, ld x2, int steps, int dir) { if(!steps) {
if(vid.linequality > 0) steps <<= vid.linequality; gridline(V, bt::get_horopoint(h0), bt::get_horopoint(h1), gridcolor(c, c->move(t)), prec);
if(vid.linequality < 0) steps >>= -vid.linequality; }
for(int i=0; i<=steps; i++) curvepoint(bt::get_horopoint(y, x1 + (x2-x1) * i / steps)); else {
queuecurve(V, gridcolor(c, c->move(dir)), 0, PPR::LINE); if(vid.linequality > 0) steps <<= vid.linequality;
}; if(vid.linequality < 0) steps >>= -vid.linequality;
horizontal(yy, 2*xx, xx, 4, bt::bd_up_right); auto step = (h1 - h0) / steps;
horizontal(yy, xx, -xx, 8, bt::bd_up); for(int i=0; i<=steps; i++) curvepoint(bt::get_horopoint(h0 + i * step));
horizontal(yy, -xx, -2*xx, 4, bt::bd_up_left); queuecurve(V, gridcolor(c, c->move(t)), 0, PPR::LINE);
}
}
} }
#endif #endif
else if(isWarped(c) && has_nice_dual()) { else if(isWarped(c) && has_nice_dual()) {

View File

@ -639,10 +639,10 @@ EX hyperpoint nearcorner(cell *c, int i) {
ld yx = log(2) / 2; ld yx = log(2) / 2;
ld yy = yx; ld yy = yx;
hyperpoint neis[5]; hyperpoint neis[5];
neis[0] = bt::get_horopoint(2*yy, -0.5); neis[0] = bt::get_horopoint(2*yy, -0.25);
neis[1] = bt::get_horopoint(2*yy, +0.5); neis[1] = bt::get_horopoint(2*yy, +0.25);
neis[2] = bt::get_horopoint(0, 1); neis[2] = bt::get_horopoint(0, 1);
neis[3] = bt::get_horopoint(-2*yy, c->master->zebraval ? -0.25 : +0.25); neis[3] = bt::get_horopoint(-2*yy, c->master->zebraval ? -0.5 : +0.5);
neis[4] = bt::get_horopoint(0, -1); neis[4] = bt::get_horopoint(0, -1);
return neis[i]; return neis[i];
} }
@ -650,11 +650,11 @@ EX hyperpoint nearcorner(cell *c, int i) {
ld yx = log(3) / 2; ld yx = log(3) / 2;
ld yy = yx; ld yy = yx;
hyperpoint neis[6]; hyperpoint neis[6];
neis[0] = bt::get_horopoint(2*yy, -1); neis[0] = bt::get_horopoint(2*yy, -1/3.);
neis[1] = bt::get_horopoint(2*yy, +0); neis[1] = bt::get_horopoint(2*yy, +0);
neis[2] = bt::get_horopoint(2*yy, +1); neis[2] = bt::get_horopoint(2*yy, +1/3.);
neis[3] = bt::get_horopoint(0, 1); neis[3] = bt::get_horopoint(0, 1);
neis[4] = bt::get_horopoint(-2*yy, c->master->zebraval / 3.); neis[4] = bt::get_horopoint(-2*yy, c->master->zebraval);
neis[5] = bt::get_horopoint(0, -1); neis[5] = bt::get_horopoint(0, -1);
return neis[i]; return neis[i];
} }
@ -674,13 +674,13 @@ EX hyperpoint nearcorner(cell *c, int i) {
// ld xx = 1 / sqrt(2)/2; // ld xx = 1 / sqrt(2)/2;
hyperpoint neis[7]; hyperpoint neis[7];
neis[0] = bt::get_horopoint(0, 1); neis[0] = bt::get_horopoint(0, 1);
neis[1] = bt::get_horopoint(yy*2, 1); neis[1] = bt::get_horopoint(yy*2, 0.5);
neis[2] = bt::get_horopoint(yy*2, 0); neis[2] = bt::get_horopoint(yy*2, 0);
neis[3] = bt::get_horopoint(yy*2, -1); neis[3] = bt::get_horopoint(yy*2, -0.5);
neis[4] = bt::get_horopoint(0, -1); neis[4] = bt::get_horopoint(0, -1);
if(c->type == 7) if(c->type == 7)
neis[5] = bt::get_horopoint(-yy*2, -.5), neis[5] = bt::get_horopoint(-yy*2, -1),
neis[6] = bt::get_horopoint(-yy*2, +.5); neis[6] = bt::get_horopoint(-yy*2, +1);
else else
neis[5] = bt::get_horopoint(-yy*2, 0); neis[5] = bt::get_horopoint(-yy*2, 0);
return neis[i]; return neis[i];