mirror of
				https://github.com/zenorogue/hyperrogue.git
				synced 2025-10-31 05:52:59 +00:00 
			
		
		
		
	ternary tiling
This commit is contained in:
		| @@ -127,6 +127,12 @@ EX namespace binary { | |||||||
|       else |       else | ||||||
|         h->emeraldval = ((parent->emeraldval - d1) * 7508 + 15015) % 15015; |         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(WDIM == 3 && h->c7) make_binary_lands(parent, h); | ||||||
|     #if DEBUG_BINARY_TILING |     #if DEBUG_BINARY_TILING | ||||||
|     xcode[h] = expected_xcode(parent, d); |     xcode[h] = expected_xcode(parent, d); | ||||||
| @@ -239,6 +245,24 @@ EX namespace binary { | |||||||
|                 return path(h, 4, 2, {3, 4, 1}); |                 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          |         #if MAXMDIM >= 4          | ||||||
|         case gBinary3: { |         case gBinary3: { | ||||||
|           switch(d) { |           switch(d) { | ||||||
| @@ -506,6 +530,7 @@ EX namespace binary { | |||||||
|    |    | ||||||
|   EX int updir() { |   EX int updir() { | ||||||
|     if(geometry == gBinary4) return 3; |     if(geometry == gBinary4) return 3; | ||||||
|  |     if(geometry == gTernary) return 4; | ||||||
|     if(geometry == gBinaryTiling) return 5; |     if(geometry == gBinaryTiling) return 5; | ||||||
|     if(penrose) return 0; |     if(penrose) return 0; | ||||||
|     if(!binarytiling) return 0; |     if(!binarytiling) return 0; | ||||||
| @@ -523,6 +548,14 @@ EX namespace binary { | |||||||
|       direct_tmatrix[4] = parabolic(-1); |       direct_tmatrix[4] = parabolic(-1); | ||||||
|       use_direct = 1+2+4+16; |       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) { |     if(geometry == gBinary3) { | ||||||
|       direct_tmatrix[0] = xpush(-log(2)) * parabolic3(-1, -1); |       direct_tmatrix[0] = xpush(-log(2)) * parabolic3(-1, -1); | ||||||
|       direct_tmatrix[1] = 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 yx = log(2) / 2; | ||||||
|   ld yy = yx; |   ld yy = yx; | ||||||
|   ld xx = 1 / sqrt(2)/2; |   ld xx = 1 / sqrt(2)/2; | ||||||
|   if(geometry == gBinaryTiling) switch(gmod(i, c->type)) { |   switch(geometry) { | ||||||
|     case 0: return point2(-yy, xx); |     case gBinaryTiling:     | ||||||
|     case 1: return point2(yy, 2*xx); |       switch(gmod(i, c->type)) { | ||||||
|     case 2: return point2(yy, xx); |         case 0: return point2(-yy, xx); | ||||||
|     case 3: return point2(yy, -xx); |         case 1: return point2(yy, 2*xx); | ||||||
|     case 4: return point2(yy, -2*xx); |         case 2: return point2(yy, xx); | ||||||
|     case 5: return point2(-yy, -xx); |         case 3: return point2(yy, -xx); | ||||||
|     case 6: return point2(-yy, 0);     |         case 4: return point2(yy, -2*xx); | ||||||
|     default: return point2(0, 0); |         case 5: return point2(-yy, -xx); | ||||||
|     } |         case 6: return point2(-yy, 0);     | ||||||
|   else switch(gmod(i, c->type)) { |         default: return point2(0, 0); | ||||||
|     case 0: return point2(yy, -2*xx); |         } | ||||||
|     case 1: return point2(yy, +0*xx); |      | ||||||
|     case 2: return point2(yy, +2*xx); |     case gBinary4: | ||||||
|     case 3: return point2(-yy, xx); |       switch(gmod(i, c->type)) { | ||||||
|     case 4: return point2(-yy, -xx); |         case 0: return point2(yy, -2*xx); | ||||||
|     default: return point2(0, 0); |         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); | ||||||
|   } |   } | ||||||
|  |  | ||||||
|  |  | ||||||
|   | |||||||
| @@ -585,8 +585,9 @@ vector<geometryinfo> ginf = { | |||||||
|   {"kd2",    "none",    "kite-and-dart",                              "kd2",      4, 3, qPENROSE,  giEuclid2, 0x48000, {{7, 7}}, eVariation::pure}, |   {"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}, |   {"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}, |   {"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}, |   {"product","none",    "product space",                              "product",  7, 3, qHYBRID,   giProduct, 0x00000, {{7, 3}}, eVariation::pure}, | ||||||
|   {"twisted","none",    "rotation space",                             "twisted",  7, 3, qHYBRID,   giSL2,     0x49000, {{6, 4}}, 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 |   // bits: 9, 10, 15, 16, (reserved for later) 17, 18 | ||||||
|   | |||||||
| @@ -215,6 +215,7 @@ enum eGeometry { | |||||||
|   gField435, gField534, |   gField435, gField534, | ||||||
|   gBinary4, gSol, |   gBinary4, gSol, | ||||||
|   gKiteDart2, gKiteDart3, gNil, gProduct, gRotSpace, |   gKiteDart2, gKiteDart3, gNil, gProduct, gRotSpace, | ||||||
|  |   gTernary,  | ||||||
|   gGUARD}; |   gGUARD}; | ||||||
|  |  | ||||||
| enum eGeometryClass { gcHyperbolic, gcEuclid, gcSphere, gcSol, gcNil, gcProduct, gcSL2 }; | enum eGeometryClass { gcHyperbolic, gcEuclid, gcSphere, gcSol, gcNil, gcProduct, gcSL2 }; | ||||||
|   | |||||||
| @@ -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) { |   else if(PURE && geometry != gBinaryTiling && geosupport_football() < 2) { | ||||||
|     cell model; |     cell model; | ||||||
|     model.type = S7;  |     model.type = S7;  | ||||||
| @@ -793,7 +804,7 @@ EX int shvid(cell *c) { | |||||||
|     return c->type-6; |     return c->type-6; | ||||||
|   else if(penrose) |   else if(penrose) | ||||||
|     return kite::getshape(c->master); |     return kite::getshape(c->master); | ||||||
|   else if(geometry == gBinary4) |   else if(geometry == gBinary4 || geometry == gTernary) | ||||||
|     return c->master->zebraval; |     return c->master->zebraval; | ||||||
|   else if(PURE) |   else if(PURE) | ||||||
|     return 0; |     return 0; | ||||||
|   | |||||||
| @@ -554,6 +554,18 @@ EX hyperpoint nearcorner(cell *c, int i) { | |||||||
|     neis[4] = binary::get_horopoint(0, -1); |     neis[4] = binary::get_horopoint(0, -1); | ||||||
|     return neis[i]; |     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(penrose) { | ||||||
|     if(approx_nearcorner) |     if(approx_nearcorner) | ||||||
|       return kite::get_corner(c, i, 3) + kite::get_corner(c, i+1, 3) - C0; |       return kite::get_corner(c, i, 3) + kite::get_corner(c, i+1, 3) - C0; | ||||||
|   | |||||||
| @@ -4619,7 +4619,7 @@ void draw_grid_at(cell *c, const transmatrix& V) { | |||||||
|     } |     } | ||||||
|   #endif |   #endif | ||||||
|   #if CAP_BT |   #if CAP_BT | ||||||
|   else if(binarytiling && WDIM == 2) { |   else if(binarytiling && WDIM == 2 && geometry != gTernary) { | ||||||
|     ld yx = log(2) / 2; |     ld yx = log(2) / 2; | ||||||
|     ld yy = yx; |     ld yy = yx; | ||||||
|     ld xx = 1 / sqrt(2)/2; |     ld xx = 1 / sqrt(2)/2; | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 Zeno Rogue
					Zeno Rogue