1
0
mirror of https://github.com/zenorogue/hyperrogue.git synced 2024-11-23 21:07:17 +00:00

cgi.cellshape is now vector of vectors

This commit is contained in:
Zeno Rogue 2021-03-25 11:12:58 +01:00
parent 4a80af6912
commit 6b594b9fc9
4 changed files with 34 additions and 32 deletions

View File

@ -1304,6 +1304,9 @@ EX void generate() {
cgi.loop = 4; cgi.loop = 4;
cgi.schmid = 3; cgi.schmid = 3;
cs.clear();
cs.resize(S7);
if(S7 == 6) { if(S7 == 6) {
cgi.adjcheck = 1; cgi.adjcheck = 1;
cgi.face = 4; cgi.face = 4;
@ -1316,7 +1319,7 @@ EX void generate() {
int x = w%3; int x = w%3;
int y = (x+2)%3; int y = (x+2)%3;
int z = (y+2)%3; int z = (y+2)%3;
cs.push_back(hpxy3(t[x]/2., t[y]/2., t[z]/2.)); cs[w].push_back(hpxy3(t[x]/2., t[y]/2., t[z]/2.));
} }
} }
} }
@ -1331,10 +1334,10 @@ EX void generate() {
int third = 3 - valid[1] - valid[0]; int third = 3 - valid[1] - valid[0];
hyperpoint v0 = cpush0(valid[0], co[valid[0]] > 0 ? 1 : -1); hyperpoint v0 = cpush0(valid[0], co[valid[0]] > 0 ? 1 : -1);
hyperpoint v1 = cpush0(valid[1], co[valid[1]] > 0 ? 1 : -1); hyperpoint v1 = cpush0(valid[1], co[valid[1]] > 0 ? 1 : -1);
cs.push_back(v0); cs[w].push_back(v0);
cs.push_back(v0/2 + v1/2 + cpush0(third, .5) - C0); cs[w].push_back(v0/2 + v1/2 + cpush0(third, .5) - C0);
cs.push_back(v1); cs[w].push_back(v1);
cs.push_back(v0/2 + v1/2 + cpush0(third, -.5) - C0); cs[w].push_back(v0/2 + v1/2 + cpush0(third, -.5) - C0);
} }
} }
@ -1345,10 +1348,10 @@ EX void generate() {
for(int w=0; w<14; w++) { for(int w=0; w<14; w++) {
if(w%7 < 3) { if(w%7 < 3) {
int z = w>=7?-1:1; int z = w>=7?-1:1;
cs.push_back(cpush0(w%7, z) + cpush0((w%7+1)%3, 1/2.) - C0); cs[w].push_back(cpush0(w%7, z) + cpush0((w%7+1)%3, 1/2.) - C0);
cs.push_back(cpush0(w%7, z) + cpush0((w%7+2)%3, 1/2.) - C0); cs[w].push_back(cpush0(w%7, z) + cpush0((w%7+2)%3, 1/2.) - C0);
cs.push_back(cpush0(w%7, z) + cpush0((w%7+1)%3,-1/2.) - C0); cs[w].push_back(cpush0(w%7, z) + cpush0((w%7+1)%3,-1/2.) - C0);
cs.push_back(cpush0(w%7, z) + cpush0((w%7+2)%3,-1/2.) - C0); cs[w].push_back(cpush0(w%7, z) + cpush0((w%7+2)%3,-1/2.) - C0);
} }
else { else {
auto t = v[w]; auto t = v[w];
@ -1356,7 +1359,7 @@ EX void generate() {
for(hyperpoint h: { for(hyperpoint h: {
hpxy3(x, y/2, 0), hpxy3(x/2, y, 0), hpxy3(0, y, z/2), hpxy3(x, y/2, 0), hpxy3(x/2, y, 0), hpxy3(0, y, z/2),
hpxy3(0, y/2, z), hpxy3(x/2, 0, z), hpxy3(x, 0, z/2) hpxy3(0, y/2, z), hpxy3(x/2, 0, z), hpxy3(x, 0, z/2)
}) cs.push_back(h); }) cs[w].push_back(h);
} }
} }
} }

View File

@ -125,7 +125,7 @@ struct geometry_information {
int loop, face, schmid; int loop, face, schmid;
vector<hyperpoint> cellshape; vector<vector<hyperpoint>> cellshape;
vector<hyperpoint> vertices_only; vector<hyperpoint> vertices_only;
transmatrix spins[32], adjmoves[32]; transmatrix spins[32], adjmoves[32];

View File

@ -999,15 +999,8 @@ void geometry_information::create_wall3d() {
} }
if(euc::in() || reg3::in()) { if(euc::in() || reg3::in()) {
int facesize = isize(cgi.cellshape) / S7; for(int w=0; w<isize(cgi.cellshape); w++)
int next = 0; make_wall(w, cgi.cellshape[w]);
for(int w=0; w<S7; w++) {
vector<hyperpoint> vertices;
if(S7 == 14) facesize = (w%7 < 3 ? 4 : 6);
for(int a=0; a<facesize; a++)
vertices.push_back(cgi.cellshape[next++]);
make_wall(w, vertices);
}
} }
if(geometry == gSol) { if(geometry == gSol) {

View File

@ -44,8 +44,9 @@ EX namespace reg3 {
hyperpoint nei; hyperpoint nei;
for(int i=0; i<isize(cgi.cellshape); i++) for(int i=0; i<isize(cgi.cellshape); i++)
if(sqhypot_d(WDIM, cgi.cellshape[i]-v) < 1e-6) for(int j=0; j<isize(cgi.cellshape[i]); j++)
nei = cgi.cellshape[i % cgi.face ? i-1 : i+1]; if(sqhypot_d(WDIM, cgi.cellshape[i][j]-v) < 1e-6)
nei = cgi.cellshape[i][j?j-1:j+1];
transmatrix T = spintox(v); transmatrix T = spintox(v);
hyperpoint a = T * v; hyperpoint a = T * v;
@ -90,7 +91,8 @@ EX namespace reg3 {
EX void make_vertices_only() { EX void make_vertices_only() {
auto& vertices_only = cgi.vertices_only; auto& vertices_only = cgi.vertices_only;
vertices_only.clear(); vertices_only.clear();
for(hyperpoint h: cgi.cellshape) { for(auto& v: cgi.cellshape)
for(hyperpoint h: v) {
bool found = false; bool found = false;
for(hyperpoint h2: vertices_only) if(hdist(h, h2) < 1e-6) found = true; for(hyperpoint h2: vertices_only) if(hdist(h, h2) < 1e-6) found = true;
if(!found) vertices_only.push_back(h); if(!found) vertices_only.push_back(h);
@ -226,9 +228,11 @@ EX namespace reg3 {
} }
cellshape.clear(); cellshape.clear();
for(int a=0; a<S7; a++) cellshape.resize(S7);
for(int b=0; b<face; b++) for(int a=0; a<S7; a++) {
cellshape.push_back(spins[a] * cspin(1, 2, 2*M_PI*b/face) * v2); for(int b=0; b<face; b++)
cellshape[a].push_back(spins[a] * cspin(1, 2, 2*M_PI*b/face) * v2);
}
cgi.adjmoves[0] = cpush(0, between_centers) * cspin(0, 2, M_PI); cgi.adjmoves[0] = cpush(0, between_centers) * cspin(0, 2, M_PI);
for(int i=1; i<S7; i++) cgi.adjmoves[i] = spins[i] * cgi.adjmoves[0]; for(int i=1; i<S7; i++) cgi.adjmoves[i] = spins[i] * cgi.adjmoves[0];
@ -254,7 +258,7 @@ EX namespace reg3 {
transmatrix T = cspin(0, 2, 90 * degree); transmatrix T = cspin(0, 2, 90 * degree);
transmatrix iT = inverse(T); transmatrix iT = inverse(T);
for(auto& v: cgi.adjmoves) v = T * v * iT; for(auto& v: cgi.adjmoves) v = T * v * iT;
for(auto& v: cellshape) v = T * v; for(auto& vv: cellshape) for(auto& v: vv) v = T * v;
} }
make_vertices_only(); make_vertices_only();
@ -1579,7 +1583,7 @@ EX void construct_relations() {
formulas.push_back(""); formulas.push_back("");
all.push_back(Id); all.push_back(Id);
hyperpoint v = cgi.cellshape[0]; hyperpoint v = cgi.cellshape[0][0];
auto add = [&] (transmatrix T) { auto add = [&] (transmatrix T) {
for(int i=0; i<isize(all); i++) if(eqmatrix(all[i], T)) return i; for(int i=0; i<isize(all); i++) if(eqmatrix(all[i], T)) return i;
int S = isize(all); int S = isize(all);
@ -1592,10 +1596,12 @@ EX void construct_relations() {
println(hlog, "cellshape = ", isize(cgi.cellshape)); println(hlog, "cellshape = ", isize(cgi.cellshape));
bool ok = true; bool ok = true;
int last_i = -1; int last_i = -1;
for(hyperpoint h: cgi.cellshape) { for(auto& v: cgi.cellshape) for(hyperpoint h: v) {
int i = 0, j = 0; int i = 0, j = 0;
for(hyperpoint u: cgi.cellshape) if(hdist(h, cgi.full_X*u) < 5e-2) i++; for(auto& uv: cgi.cellshape) for(hyperpoint u: uv) {
for(hyperpoint u: cgi.cellshape) if(hdist(h, cgi.full_R*u) < 5e-2) j++; if(hdist(h, cgi.full_X*u) < 5e-2) i++;
if(hdist(h, cgi.full_R*u) < 5e-2) j++;
}
if(last_i == -1) last_i = i; if(last_i == -1) last_i = i;
if(i != j || i != last_i) ok = false; if(i != j || i != last_i) ok = false;
} }
@ -1606,7 +1612,7 @@ EX void construct_relations() {
auto work = [&] (transmatrix T, int p, char c) { auto work = [&] (transmatrix T, int p, char c) {
if(hdist0(tC0(T)) > 5) return; if(hdist0(tC0(T)) > 5) return;
for(hyperpoint h: cgi.cellshape) if(hdist(T * h, v) < 1e-4) goto ok; for(auto& hv: cgi.cellshape) for(hyperpoint h: hv) if(hdist(T * h, v) < 1e-4) goto ok;
return; return;
ok: ok:
int id = add(T); int id = add(T);