From 33d94beb4fa1e21e1c5d856db06d09695d7469b4 Mon Sep 17 00:00:00 2001 From: ? Date: Sun, 24 Feb 2019 23:06:52 +0100 Subject: [PATCH] moved spherical geometry to sphere.cpp --- cell.cpp | 161 ----------------------------------------------- compileunits.h | 1 + sphere.cpp | 167 +++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 168 insertions(+), 161 deletions(-) create mode 100644 sphere.cpp diff --git a/cell.cpp b/cell.cpp index 453e947e..f7b067c2 100644 --- a/cell.cpp +++ b/cell.cpp @@ -84,167 +84,6 @@ hrmap_hyperbolic::hrmap_hyperbolic() { h.c7 = newCell(S7, origin); } -// --- spherical geometry --- - -int spherecells() { - if(S7 == 5) return (elliptic?6:12); - if(S7 == 4) return (elliptic?3:6); - if(S7 == 3 && S3 == 4) return (elliptic?4:8); - if(S7 == 3) return 4; - if(S7 == 2) return (elliptic?1:2); - if(S7 == 1) return 1; - return 12; - } - -vector siblings; - -struct hrmap_spherical : hrmap { - heptagon *dodecahedron[12]; - eVariation mvar; - - hrmap_spherical() { - mvar = variation; - for(int i=0; i (S7)); - h.s = hsOrigin; - h.emeraldval = i; - h.zebraval = i; - h.fiftyval = i; - h.rval0 = h.rval1 = 0; - h.alt = NULL; - h.cdata = NULL; - h.c.fullclear(); - h.fieldval = i; - if(!IRREGULAR) h.c7 = newCell(S7, &h); - } - if(S7 == 5) - siblings = {1, 0, 10, 4, 3, 8, 9, 11, 5, 6, 2, 7}; - else - siblings = {1, 0, 3, 2, 5, 4}; - - if(S7 == 3 && S3 == 4) { - for(int i=0; i<8; i++) { - dodecahedron[i]->move(0) = dodecahedron[i^1]; - dodecahedron[i]->c.setspin(0, 0, false); - dodecahedron[i]->move(1) = dodecahedron[i^2]; - dodecahedron[i]->c.setspin(1, 1, false); - dodecahedron[i]->move(2) = dodecahedron[i^4]; - dodecahedron[i]->c.setspin(2, 2, false); - } - for(int i=0; i<8; i++) { - int s = (i&1)+((i&2)>>1)+((i&4)>>2); - if((s&1) == 1) { - swap(dodecahedron[i]->move(1), dodecahedron[i]->move(2)); - int a = dodecahedron[i]->c.spin(1); - int b = dodecahedron[i]->c.spin(2); - dodecahedron[i]->c.setspin(1, b, false); - dodecahedron[i]->c.setspin(2, a, false); - dodecahedron[i]->move(1)->c.setspin(b, 1, false); - dodecahedron[i]->move(2)->c.setspin(a, 2, false); - } - } - for(int i=0; i<8; i++) - for(int j=0; j<3; j++) - if(dodecahedron[i]->move(j)->move(dodecahedron[i]->c.spin(j)) != dodecahedron[i]) - println(hlog, "8"); - } - - else if(S7 == 4 && elliptic) { - for(int i=0; i<3; i++) { - int i1 = (i+1)%3; - int i2 = (i+2)%3; - dodecahedron[i]->move(0) = dodecahedron[i1]; - dodecahedron[i]->c.setspin(0, 1, false); - dodecahedron[i]->move(1) = dodecahedron[i2]; - dodecahedron[i]->c.setspin(1, 0, false); - dodecahedron[i]->move(2) = dodecahedron[i1]; - dodecahedron[i]->c.setspin(2, 3, true); - dodecahedron[i]->move(3) = dodecahedron[i2]; - dodecahedron[i]->c.setspin(3, 2, true); - } - } - else for(int i=0; imove(i) = dodecahedron[i+1]; - dodecahedron[0]->c.setspin(i, 0, false); - dodecahedron[i+1]->move(0) = dodecahedron[0]; - dodecahedron[i+1]->c.setspin(0, i, false); - - dodecahedron[i+1]->move(1) = dodecahedron[(i+S7-1)%S7+1]; - dodecahedron[i+1]->c.setspin(1, S7-1, false); - dodecahedron[i+1]->move(S7-1) = dodecahedron[(i+1)%S7+1]; - dodecahedron[i+1]->c.setspin(S7-1, 1, false); - - if(S7 == 5 && elliptic) { - dodecahedron[i+1]->move(2) = dodecahedron[(i+2)%S7+1]; - dodecahedron[i+1]->c.setspin(2, 3, true); - dodecahedron[i+1]->move(3) = dodecahedron[(i+3)%S7+1]; - dodecahedron[i+1]->c.setspin(3, 2, true); - } - - else if(S7 == 5) { - dodecahedron[6]->move(i) = dodecahedron[7+i]; - dodecahedron[6]->c.setspin(i, 0, false); - dodecahedron[7+i]->move(0) = dodecahedron[6]; - dodecahedron[7+i]->c.setspin(0, i, false); - - dodecahedron[i+7]->move(1) = dodecahedron[(i+4)%5+7]; - dodecahedron[i+7]->c.setspin(1, 4, false); - dodecahedron[i+7]->move(4) = dodecahedron[(i+1)%5+7]; - dodecahedron[i+7]->c.setspin(4, 1, false); - - dodecahedron[i+1]->move(2) = dodecahedron[7+(10-i)%5]; - dodecahedron[i+1]->c.setspin(2, 2, false); - dodecahedron[7+(10-i)%5]->move(2) = dodecahedron[1+i]; - dodecahedron[7+(10-i)%5]->c.setspin(2, 2, false); - - dodecahedron[i+1]->move(3) = dodecahedron[7+(9-i)%5]; - dodecahedron[i+1]->c.setspin(3, 3, false); - dodecahedron[7+(9-i)%5]->move(3) = dodecahedron[i+1]; - dodecahedron[7+(9-i)%5]->c.setspin(3, 3, false); - } - if(S7 == 4) { - dodecahedron[5]->move(3-i) = dodecahedron[i+1]; - dodecahedron[5]->c.setspin(3-i, 2, false); - dodecahedron[i+1]->move(2) = dodecahedron[5]; - dodecahedron[i+1]->c.setspin(2, 3-i, false); - } - } - - #if CAP_IRR - if(IRREGULAR) { - irr::link_start(dodecahedron[0]); - for(int i=0; i ph(variation, mvar); - for(int i=0; i (currentmap); - if(!s) return NULL; - return s->dodecahedron[i]; - } - // --- quotient geometry --- namespace quotientspace { diff --git a/compileunits.h b/compileunits.h index cdc14696..075d30ae 100644 --- a/compileunits.h +++ b/compileunits.h @@ -32,6 +32,7 @@ #include "binary-tiling.cpp" #include "archimedean.cpp" #include "euclid.cpp" +#include "sphere.cpp" #include "crystal.cpp" #include "language.cpp" #include "cell.cpp" diff --git a/sphere.cpp b/sphere.cpp new file mode 100644 index 00000000..7e25e33d --- /dev/null +++ b/sphere.cpp @@ -0,0 +1,167 @@ +// Hyperbolic Rogue -- spherical spaces +// Copyright (C) 2011-2018 Zeno Rogue, see 'hyper.cpp' for details + +namespace hr { + +// --- spherical geometry --- + +int spherecells() { + if(S7 == 5) return (elliptic?6:12); + if(S7 == 4) return (elliptic?3:6); + if(S7 == 3 && S3 == 4) return (elliptic?4:8); + if(S7 == 3) return 4; + if(S7 == 2) return (elliptic?1:2); + if(S7 == 1) return 1; + return 12; + } + +vector siblings; + +struct hrmap_spherical : hrmap { + heptagon *dodecahedron[12]; + eVariation mvar; + + hrmap_spherical() { + mvar = variation; + for(int i=0; i (S7)); + h.s = hsOrigin; + h.emeraldval = i; + h.zebraval = i; + h.fiftyval = i; + h.rval0 = h.rval1 = 0; + h.alt = NULL; + h.cdata = NULL; + h.c.fullclear(); + h.fieldval = i; + if(!IRREGULAR) h.c7 = newCell(S7, &h); + } + if(S7 == 5) + siblings = {1, 0, 10, 4, 3, 8, 9, 11, 5, 6, 2, 7}; + else + siblings = {1, 0, 3, 2, 5, 4}; + + if(S7 == 3 && S3 == 4) { + for(int i=0; i<8; i++) { + dodecahedron[i]->move(0) = dodecahedron[i^1]; + dodecahedron[i]->c.setspin(0, 0, false); + dodecahedron[i]->move(1) = dodecahedron[i^2]; + dodecahedron[i]->c.setspin(1, 1, false); + dodecahedron[i]->move(2) = dodecahedron[i^4]; + dodecahedron[i]->c.setspin(2, 2, false); + } + for(int i=0; i<8; i++) { + int s = (i&1)+((i&2)>>1)+((i&4)>>2); + if((s&1) == 1) { + swap(dodecahedron[i]->move(1), dodecahedron[i]->move(2)); + int a = dodecahedron[i]->c.spin(1); + int b = dodecahedron[i]->c.spin(2); + dodecahedron[i]->c.setspin(1, b, false); + dodecahedron[i]->c.setspin(2, a, false); + dodecahedron[i]->move(1)->c.setspin(b, 1, false); + dodecahedron[i]->move(2)->c.setspin(a, 2, false); + } + } + for(int i=0; i<8; i++) + for(int j=0; j<3; j++) + if(dodecahedron[i]->move(j)->move(dodecahedron[i]->c.spin(j)) != dodecahedron[i]) + println(hlog, "8"); + } + + else if(S7 == 4 && elliptic) { + for(int i=0; i<3; i++) { + int i1 = (i+1)%3; + int i2 = (i+2)%3; + dodecahedron[i]->move(0) = dodecahedron[i1]; + dodecahedron[i]->c.setspin(0, 1, false); + dodecahedron[i]->move(1) = dodecahedron[i2]; + dodecahedron[i]->c.setspin(1, 0, false); + dodecahedron[i]->move(2) = dodecahedron[i1]; + dodecahedron[i]->c.setspin(2, 3, true); + dodecahedron[i]->move(3) = dodecahedron[i2]; + dodecahedron[i]->c.setspin(3, 2, true); + } + } + else for(int i=0; imove(i) = dodecahedron[i+1]; + dodecahedron[0]->c.setspin(i, 0, false); + dodecahedron[i+1]->move(0) = dodecahedron[0]; + dodecahedron[i+1]->c.setspin(0, i, false); + + dodecahedron[i+1]->move(1) = dodecahedron[(i+S7-1)%S7+1]; + dodecahedron[i+1]->c.setspin(1, S7-1, false); + dodecahedron[i+1]->move(S7-1) = dodecahedron[(i+1)%S7+1]; + dodecahedron[i+1]->c.setspin(S7-1, 1, false); + + if(S7 == 5 && elliptic) { + dodecahedron[i+1]->move(2) = dodecahedron[(i+2)%S7+1]; + dodecahedron[i+1]->c.setspin(2, 3, true); + dodecahedron[i+1]->move(3) = dodecahedron[(i+3)%S7+1]; + dodecahedron[i+1]->c.setspin(3, 2, true); + } + + else if(S7 == 5) { + dodecahedron[6]->move(i) = dodecahedron[7+i]; + dodecahedron[6]->c.setspin(i, 0, false); + dodecahedron[7+i]->move(0) = dodecahedron[6]; + dodecahedron[7+i]->c.setspin(0, i, false); + + dodecahedron[i+7]->move(1) = dodecahedron[(i+4)%5+7]; + dodecahedron[i+7]->c.setspin(1, 4, false); + dodecahedron[i+7]->move(4) = dodecahedron[(i+1)%5+7]; + dodecahedron[i+7]->c.setspin(4, 1, false); + + dodecahedron[i+1]->move(2) = dodecahedron[7+(10-i)%5]; + dodecahedron[i+1]->c.setspin(2, 2, false); + dodecahedron[7+(10-i)%5]->move(2) = dodecahedron[1+i]; + dodecahedron[7+(10-i)%5]->c.setspin(2, 2, false); + + dodecahedron[i+1]->move(3) = dodecahedron[7+(9-i)%5]; + dodecahedron[i+1]->c.setspin(3, 3, false); + dodecahedron[7+(9-i)%5]->move(3) = dodecahedron[i+1]; + dodecahedron[7+(9-i)%5]->c.setspin(3, 3, false); + } + if(S7 == 4) { + dodecahedron[5]->move(3-i) = dodecahedron[i+1]; + dodecahedron[5]->c.setspin(3-i, 2, false); + dodecahedron[i+1]->move(2) = dodecahedron[5]; + dodecahedron[i+1]->c.setspin(2, 3-i, false); + } + } + + #if CAP_IRR + if(IRREGULAR) { + irr::link_start(dodecahedron[0]); + for(int i=0; i ph(variation, mvar); + for(int i=0; i (currentmap); + if(!s) return NULL; + return s->dodecahedron[i]; + } + +}