#include "../hyper.h" // usage: -viz -geo 1 -canvas i -zoom .2 -shot-1000 -magmashape N // where N = 1, 2, 3, 4 namespace hr { int magmav = 7; /* vertices of the Magma's heptagon */ vector vertices; hyperpoint hcenter; /* how are all Magma's heptagons transformed and colored */ vector> heps; int magmashape = 0; int magmacount = 1000; int magmalong = 10; bool magmadebug = false; /* transformation from the original to the next heptagon; edge a of the original heptagon matches edge b of the next heptagon */ EX transmatrix get_adj(int a, int b) { hyperpoint vl = vertices[a]; hyperpoint vr = vertices[a+1]; hyperpoint vm = mid(vl, vr); transmatrix rm = gpushxto0(vm); hyperpoint xvl = vertices[b]; hyperpoint xvr = vertices[b+1]; hyperpoint xvm = mid(xvl, xvr); transmatrix xrm = gpushxto0(xvm); transmatrix Res = rgpushxto0(vm) * rspintox(rm*vr); Res = Res * spintox(xrm*xvl) * xrm; return Res; } pair hash(hyperpoint h) { return {int(h[0] * 1000000 + .5), int(h[1] * 1000000 + .5)}; } void make() { int& v = magmav; /* compute the vertices */ vertices.resize(magmav+1); for(int i=0; i<=magmav; i++) vertices[i] = spin(TAU*(i+(v-7)/4.)/v) * xpush0(1); ld xx = vertices[2][0]; int down = v/2 + 2; for(int k=3; k, int> counts; int big = v - 2; auto rehash = [&] (const transmatrix& T) { for(int a=0; a 2 && a < down) counts[hashval] += 2*v - big; else counts[hashval] += big; } }; heps.emplace_back(Id, 0xFFFFFFFF); auto advance = [&] (int i, int j, bool mirror = false) { transmatrix T = heps.back().first * get_adj(i, j); if(mirror) T = T * MirrorY; heps.emplace_back(T, heps.back().second ^ 0xFFFF00); }; /* create the core */ int last = v-1; int t = 3; switch(magmashape) { case 1: for(int i=1; i<2*v; i++) advance(0, t); break; case 2: for(int i=0; igamestart()); int id = 0; for(auto h: heps) draw_at(V * h.first, h.second, id++); } int readArgs() { using namespace arg; if(0) ; else if(argis("-magmashape")) { shift(); magmashape = argi(); } else if(argis("-magmav")) { shift(); magmav = argi(); } else if(argis("-magmacount")) { shift(); magmacount = argi(); } else if(argis("-magmalong")) { shift(); magmalong = argi(); } else if(argis("-magmadebug")) { shift(); magmadebug = argi(); } else return 1; return 0; } auto msc = addHook(hooks_frame, 100, draw_magma) + addHook(hooks_args, 100, readArgs); }