From 255186840f4dde813b53264ec497bef9829abb32 Mon Sep 17 00:00:00 2001 From: Zeno Rogue Date: Mon, 30 Sep 2019 23:36:15 +0200 Subject: [PATCH] ternary tiling --- binary-tiling.cpp | 89 ++++++++++++++++++++++++++++++++++++++--------- classes.cpp | 5 +-- classes.h | 1 + floorshapes.cpp | 13 ++++++- geometry2.cpp | 12 +++++++ graph.cpp | 2 +- 6 files changed, 101 insertions(+), 21 deletions(-) diff --git a/binary-tiling.cpp b/binary-tiling.cpp index a84d75de..94d35403 100644 --- a/binary-tiling.cpp +++ b/binary-tiling.cpp @@ -127,6 +127,12 @@ EX namespace binary { else h->emeraldval = ((parent->emeraldval - d1) * 7508 + 15015) % 15015; } + if(geometry == gTernary) { + if(d < 2) + h->emeraldval = (parent->emeraldval * 3 + d) % 10010; + else + h->emeraldval = ((parent->emeraldval - d1) * 3337 + 2*10010) % 10010; + } if(WDIM == 3 && h->c7) make_binary_lands(parent, h); #if DEBUG_BINARY_TILING xcode[h] = expected_xcode(parent, d); @@ -239,6 +245,24 @@ EX namespace binary { return path(h, 4, 2, {3, 4, 1}); } } + case gTernary: { + switch(d) { + case 0: case 1: case 2: + return build(parent, d, 4, 6, d, 1); + case 4: + return build(parent, 4, parent->zebraval, 6, nextdir(3), -1); + case 3: + if(parent->zebraval < 2) + return path(h, 3, 5, {4, parent->zebraval + 1}); + else + return path(h, 3, 5, {4, 3, 0}); + case 5: + if(parent->zebraval > 0) + return path(h, 5, 3, {4, parent->zebraval - 1}); + else + return path(h, 5, 3, {4, 5, 2}); + } + } #if MAXMDIM >= 4 case gBinary3: { switch(d) { @@ -506,6 +530,7 @@ EX namespace binary { EX int updir() { if(geometry == gBinary4) return 3; + if(geometry == gTernary) return 4; if(geometry == gBinaryTiling) return 5; if(penrose) return 0; if(!binarytiling) return 0; @@ -523,6 +548,14 @@ EX namespace binary { direct_tmatrix[4] = parabolic(-1); use_direct = 1+2+4+16; } + if(geometry == gTernary) { + direct_tmatrix[0] = xpush(-log(3)) * parabolic(-1); + direct_tmatrix[1] = xpush(-log(3)); + direct_tmatrix[2] = xpush(-log(3)) * parabolic(+1); + direct_tmatrix[3] = parabolic(1); + direct_tmatrix[5] = parabolic(-1); + use_direct = 1+2+4+8+32; + } if(geometry == gBinary3) { direct_tmatrix[0] = xpush(-log(2)) * parabolic3(-1, -1); direct_tmatrix[1] = xpush(-log(2)) * parabolic3(1, -1); @@ -892,24 +925,46 @@ EX hyperpoint get_corner_horo_coordinates(cell *c, int i) { ld yx = log(2) / 2; ld yy = yx; ld xx = 1 / sqrt(2)/2; - if(geometry == gBinaryTiling) 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); - } - else switch(gmod(i, c->type)) { - case 0: return point2(yy, -2*xx); - case 1: return point2(yy, +0*xx); - case 2: return point2(yy, +2*xx); - case 3: return point2(-yy, xx); - case 4: return point2(-yy, -xx); - default: return point2(0, 0); + switch(geometry) { + case gBinaryTiling: + 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); + } + + case gBinary4: + switch(gmod(i, c->type)) { + case 0: return point2(yy, -2*xx); + case 1: return point2(yy, +0*xx); + case 2: return point2(yy, +2*xx); + case 3: return point2(-yy, xx); + case 4: return point2(-yy, -xx); + default: return point2(0, 0); + } + + case gTernary: + yy = log(3) / 2; + xx = 1 / sqrt(3) / 2; + switch(gmod(i, c->type)) { + case 0: return point2(yy, -3*xx); + case 1: return point2(yy, -1*xx); + case 2: return point2(yy, +1*xx); + case 3: return point2(yy, +3*xx); + case 4: return point2(-yy, xx); + case 5: return point2(-yy, -xx); + default: return point2(0, 0); + } + + default: + return point2(0, 0); } + return point2(0, 0); } diff --git a/classes.cpp b/classes.cpp index 7b31de76..f9b6f07a 100644 --- a/classes.cpp +++ b/classes.cpp @@ -585,8 +585,9 @@ vector ginf = { {"kd2", "none", "kite-and-dart", "kd2", 4, 3, qPENROSE, giEuclid2, 0x48000, {{7, 7}}, eVariation::pure}, {"kd3", "none", "kite-and-dart on horospheres", "kd3", 12, 3, qsBP, giHyperb3, 0x48200, {{7, 3}}, eVariation::pure}, {"nil", "none", "Nil geometry", "nil", 6, 3, 0, giNil, 0x48600, {{7, 5}}, eVariation::pure}, - {"product","none", "product space", "product", 7, 3, qHYBRID, giProduct, 0x48400, {{7, 3}}, eVariation::pure}, - {"twisted","none", "rotation space", "twisted", 7, 3, qHYBRID, giSL2, 0x49000, {{6, 4}}, eVariation::pure}, + {"product","none", "product space", "product", 7, 3, qHYBRID, giProduct, 0x00000, {{7, 3}}, eVariation::pure}, + {"twisted","none", "rotation space", "twisted", 7, 3, qHYBRID, giSL2, 0x00000, {{6, 4}}, eVariation::pure}, + {"ternary","none", "standard ternary tiling", "ternary", 6, 3, qBINARY, giHyperb2, 0x48400, {{6, 4}}, eVariation::pure}, }; // bits: 9, 10, 15, 16, (reserved for later) 17, 18 diff --git a/classes.h b/classes.h index c3ce6d37..51bc2a20 100644 --- a/classes.h +++ b/classes.h @@ -215,6 +215,7 @@ enum eGeometry { gField435, gField534, gBinary4, gSol, gKiteDart2, gKiteDart3, gNil, gProduct, gRotSpace, + gTernary, gGUARD}; enum eGeometryClass { gcHyperbolic, gcEuclid, gcSphere, gcSol, gcNil, gcProduct, gcSL2 }; diff --git a/floorshapes.cpp b/floorshapes.cpp index 43536788..6367daa2 100644 --- a/floorshapes.cpp +++ b/floorshapes.cpp @@ -673,6 +673,17 @@ void geometry_information::generate_floorshapes() { } } + else if(geometry == gTernary) { + heptagon modelh; + cell model; + model.master = &modelh; + model.type = S7; + for(int i: {0,1,2}) { + modelh.zebraval = i; + generate_floorshapes_for(i, &model, 1, 0); + } + } + else if(PURE && geometry != gBinaryTiling && geosupport_football() < 2) { cell model; model.type = S7; @@ -793,7 +804,7 @@ EX int shvid(cell *c) { return c->type-6; else if(penrose) return kite::getshape(c->master); - else if(geometry == gBinary4) + else if(geometry == gBinary4 || geometry == gTernary) return c->master->zebraval; else if(PURE) return 0; diff --git a/geometry2.cpp b/geometry2.cpp index d187f7ed..fd6f64b8 100644 --- a/geometry2.cpp +++ b/geometry2.cpp @@ -554,6 +554,18 @@ EX hyperpoint nearcorner(cell *c, int i) { neis[4] = binary::get_horopoint(0, -1); return neis[i]; } + if(geometry == gTernary) { + ld yx = log(3) / 2; + ld yy = yx; + hyperpoint neis[6]; + neis[0] = binary::get_horopoint(2*yy, -1); + neis[1] = binary::get_horopoint(2*yy, +0); + neis[2] = binary::get_horopoint(2*yy, +1); + neis[3] = binary::get_horopoint(0, 1); + neis[4] = binary::get_horopoint(-2*yy, c->master->zebraval / 3.); + neis[5] = binary::get_horopoint(0, -1); + return neis[i]; + } if(penrose) { if(approx_nearcorner) return kite::get_corner(c, i, 3) + kite::get_corner(c, i+1, 3) - C0; diff --git a/graph.cpp b/graph.cpp index d196813d..17e8605b 100644 --- a/graph.cpp +++ b/graph.cpp @@ -4619,7 +4619,7 @@ void draw_grid_at(cell *c, const transmatrix& V) { } #endif #if CAP_BT - else if(binarytiling && WDIM == 2) { + else if(binarytiling && WDIM == 2 && geometry != gTernary) { ld yx = log(2) / 2; ld yy = yx; ld xx = 1 / sqrt(2)/2;