#include "../hyper.h" // Impossible Triangle visualization // used in: https://www.youtube.com/watch?v=YmFDd49WsrY // settings: // ./mymake -O3 rogueviz/triangle // ./hyper -geo Nil -canvas x -tstep 8 -nilperiod 3 3 3 // also used in: https://youtu.be/RPL4-Ydviug // ./hyper -geo Nil -nilwidth .9 -canvas x -tstep 1 -nilperiod 1 10 1 -triset 32 31 992 // network of triangles: // ./hyper -geo Nil -canvas x -tri-net namespace hr { bool net = false; EX hyperpoint lerp(hyperpoint a0, hyperpoint a1, ld x) { return a0 + (a1-a0) * x; } hyperpoint operator+(hyperpoint x) { return x; } // do not change this int shape = 1; // how many cubes to subdivide edges to int how = 8; // how many cubes to draw (should be smaller than how because they are not really cubes and thus they get into each other) int how1 = how - 1; // precision: number of substeps to simulate (best if divisible by how and how1) int isteps = 4 * 1024; struct triangledata { hyperpoint at; bool computed; int tcolor; int id; // each color group (i.e., each face direction) is a different hpcshape triangledata(hyperpoint h) : at(h), computed(false) { tcolor = 0; id = 0; } }; struct trianglemaker { map > tds; array ptriangle; array pcube; hyperpoint ds[4], uds[4], dmoves[6]; ld scale; void init() { ld rest = sqrt(8/9.); ld rex = sqrt(1 - 1/9. - pow(rest/2., 2)); ds[0] = point3(rex, -rest/2, -1/3.); ds[1] = point3(0, rest, -1/3.); ds[2] = point3(-rex, -rest/2, -1/3.); ds[3] = point3(0, 0, +1); hyperpoint start = point31(0, 0, 0); double lastz; double lasta; double ca; // compute how to scale this in Nil so that everything fits for(ld a = 1e-5;; a+=1e-5) { hyperpoint at = start; for(int d=0; d<3; d++) { for(int i=0; i 50000) break; } for(int s=0; s<8; s++) for(int t=0; t<3; t++) { if((s & (1<=0; k--) for(int l=k-1; l>=0; l--) if(matrix[l][k]) matrix[l][v] -= matrix[l][k] * matrix[k][v]; coef.resize(v); for(int i=0; i= 4) println(hlog, "D4 = ", cnts[a-4] - 4 * cnts[a-3] + 6 * cnts[a-2] - 4 * cnts[a-1] + cnts[a]); println(hlog, "cnts = ", cnts); }*/ cnts = {1,7,31,113,299,681,1363,2501,4181,6570,9874,14256,20027,27601,37171,48815,62993,79912,100181,123868,151680,184339,222347,265733,314523,369424,431221,500952,578350,665794,763300,871250,988488,1116635,1256293,1409165,1575969,1758327,1958977,2174877}; find_coefficients(); println(hlog, "coefficients_known = ", coefficients_known); if(coefficients_known == 2) { string fmt = "a(d+" + its(isize(coef)) + ") = "; bool first = true; for(int i=0; i 1) fmt += " + " + its(coef[i]); else if(coef[i] < -1) fmt += " - " + its(-coef[i]); fmt += "a(d"; if(i != isize(coef) - 1) fmt += "+" + its(isize(coef) - 1 - i); fmt += ")"; first = false; } fmt += " (d>" + its(valid_from-1) + ")"; println(hlog, fmt); } } color_t tcolors[3] = { 0xFF0000FF, 0x00FF00FF, 0x0000FFFF }; bool draw_ptriangle(cell *c, const transmatrix& V) { if(!mkr) { mkr = new trianglemaker; mkr->init(); growthrate(); } for(auto& td: mkr->tds[c]) { mkr->compute(td, c); for(int side=0; side<6; side++) { auto &s = queuepoly(V * nisot::translate(td.at), mkr->ptriangle[side], magiccolors[side]); ensure_vertex_number(*s.tinf, s.cnt); /* auto& s1 = queuepoly(V * nisot::translate(td.at), mkr->pcube[side], gradient(tcolors[td.tcolor], magiccolors[side], 0, .2, 1)); ensure_vertex_number(*s1.tinf, s1.cnt); */ } } return false; } auto hchook = addHook(hooks_drawcell, 100, draw_ptriangle) + addHook(hooks_args, 100, [] { using namespace arg; if(0) ; else if(argis("-triset")) { shift(); how = argi(); shift(); how1 = argi(); shift(); isteps = argi(); } else if(argis("-tri-net")) { net = true; } else return 1; return 0; }); }