ternary tiling

This commit is contained in:
Zeno Rogue 2019-09-30 23:36:15 +02:00
parent a971ffd427
commit 255186840f
6 changed files with 101 additions and 21 deletions

View File

@ -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);
}

View File

@ -585,8 +585,9 @@ vector<geometryinfo> 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

View File

@ -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 };

View File

@ -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;

View File

@ -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;

View File

@ -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;