diff --git a/rogueviz/triangle.cpp b/rogueviz/triangle.cpp index 21cd4832..f330a062 100644 --- a/rogueviz/triangle.cpp +++ b/rogueviz/triangle.cpp @@ -12,10 +12,13 @@ // ./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 { -// each color group (i.e., each face direction) is a different hpcshape -hpcshape ptriangle[6]; +bool net = false; EX hyperpoint lerp(hyperpoint a0, hyperpoint a1, ld x) { return a0 + (a1-a0) * x; @@ -35,123 +38,130 @@ int how1 = how - 1; // precision: number of substeps to simulate (best if divisible by how and how1) int isteps = 4 * 1024; -/* make the impossible triangle shape */ -void make_shape() { +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; } + }; - static bool done = false; - if(done) return; - done = true; - - // four main axes of the regular tetrahedron, rotated so that ds[3] points to (0,0,1) - - ld rest = sqrt(8/9.); - ld rex = sqrt(1 - 1/9. - pow(rest/2., 2)); +struct trianglemaker { - hyperpoint ds[4]; + map > tds; + + array ptriangle; + + array pcube; - 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 ds[4], uds[4], dmoves[6]; - hyperpoint start = point31(0, 0, 0); + 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); - double lastz; + 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; } - else { - verts[id][j] -= eps; - } - att++; - if(att > 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; } @@ -290,6 +481,9 @@ auto hchook = addHook(hooks_drawcell, 100, draw_ptriangle) shift(); how1 = argi(); shift(); isteps = argi(); } + else if(argis("-tri-net")) { + net = true; + } else return 1; return 0; });