From bcdd404e421f9ea6514b210500833a7325b2c9d3 Mon Sep 17 00:00:00 2001 From: Zeno Rogue Date: Mon, 8 Jun 2020 12:25:27 +0200 Subject: [PATCH] magmahep: generalized to not only heptagons, debug disable --- rogueviz/magmahep.cpp | 157 ++++++++++++++++++++++++------------------ 1 file changed, 90 insertions(+), 67 deletions(-) diff --git a/rogueviz/magmahep.cpp b/rogueviz/magmahep.cpp index 6ef568bc..0fa2c0cd 100644 --- a/rogueviz/magmahep.cpp +++ b/rogueviz/magmahep.cpp @@ -5,8 +5,12 @@ namespace hr { +int magmav = 7; + /* vertices of the Magma's heptagon */ -array vertices; +vector vertices; + +hyperpoint hcenter; /* how are all Magma's heptagons transformed and colored */ vector> heps; @@ -17,6 +21,8 @@ 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 */ @@ -43,12 +49,22 @@ EX transmatrix get_adj(int a, int b) { void make() { + int& v = magmav; + /* compute the vertices */ - for(int i=0; i<=7; i++) - vertices[i] = spin(2*M_PI*i/7) * xpush0(1); + vertices.resize(magmav+1); + for(int i=0; i<=magmav; i++) + vertices[i] = spin(2*M_PI*(i+(v-7)/4.)/v) * xpush0(1); ld xx = vertices[2][0]; - vertices[3][0] = 2 * xx - vertices[3][0]; - vertices[4][0] = 2 * xx - vertices[4][0]; + + int down = v/2 + 2; + + for(int k=3; k 2 && a < down) + total += 2*v - big; + else + total += big; } - if(small == 14 && inner == 0 && big == 0) - advance(5, 5, true); + println(hlog, "total ", total); + if(total == 2*v) + advance(down, down, true); - else if(small == 4 && big == 2 && inner == 0) - advance(5, 5, true); - - else if(small == 9 && big == 1 && inner == 0) - advance(5, 5, true); - - else if(inner == 1 && small == 5 && big == 0) - advance(5, 5, true); - - else if(small == 4 && big == 1 && inner == 0) - advance(3, 6); - else if(big == 1 && small < 4 && inner == 0) - advance(3, 0); - else if(big == 2 && small < 4 && inner == 0) - advance(3, 0); - - else { - println(hlog, "big = ", big, "small = ", small); - } + else if(total == 2 * v - big) + advance(t, last); + else if(total < 2 * v) + advance(t, 0); + else + break; } } -void draw_at(transmatrix T, color_t col) { - for(int i=0; i<=7; i++) +void draw_at(transmatrix T, color_t col, int id) { + for(int i=0; i<=magmav; i++) curvepoint(T * vertices[i]); queuecurve(0xFF, col, PPR::LINE); - for(int i=0; i<7; i++) { - hyperpoint h = mid(vertices[i], vertices[i+1]); - h += spin(M_PI/2) * (vertices[i+1] - vertices[i]) * (among(i, 2, 3, 4) ? 1 : 1) * .05; - queuestr(T * rgpushxto0(h), 0.4, its(i), 0x80); + if(magmadebug) { + for(int i=0; igamestart()); + int id = 0; for(auto h: heps) - draw_at(V * h.first, h.second); + draw_at(V * h.first, h.second, id++); } int readArgs() { @@ -190,6 +205,10 @@ int readArgs() { shift(); magmashape = argi(); } + else if(argis("-magmav")) { + shift(); magmav = argi(); + } + else if(argis("-magmacount")) { shift(); magmacount = argi(); } @@ -198,6 +217,10 @@ int readArgs() { shift(); magmalong = argi(); } + else if(argis("-magmadebug")) { + shift(); magmadebug = argi(); + } + else return 1; return 0; }