From e5ebac156ef270157e949b85ecaee61d286b1311 Mon Sep 17 00:00:00 2001 From: Zeno Rogue Date: Tue, 27 Nov 2018 16:15:32 +0100 Subject: [PATCH] calc_relative_matrix for euwrap geometries now uses cellrelmatrix nicely --- geometry2.cpp | 31 +++++++++++++------------------ 1 file changed, 13 insertions(+), 18 deletions(-) diff --git a/geometry2.cpp b/geometry2.cpp index 454e58ee..53c9496c 100644 --- a/geometry2.cpp +++ b/geometry2.cpp @@ -83,27 +83,22 @@ transmatrix calc_relative_matrix(cell *c2, cell *c1, const hyperpoint& point_hin if(euwrap) { transmatrix t = Id; - if(whateveri) printf("[%p,%d] ", c2, celldistance(c2, c1)); - int mirrors = 0; - approach: + // if(whateveri) printf("[%p,%d] ", c2, celldistance(c2, c1)); int d = celldistance(c2, c1); - forCellIdEx(c3, i, c2) { - if(celldistance(c3, c1) < d) { - if(whateveri) printf(" %d [%p,%d]", i, c3, celldistance(c3, c1)); - if(c2->type < 8) - t = eumovedir(i+(euclid6?3:2)) * t; - else if(i&1) - t = eumovedir(2+i/2) * eumovedir(2+(i+1)/2) * t; - else - t = eumovedir(2+i/2) * t; - if(c2->c.mirror(i)) mirrors++; - c2 = c3; - goto approach; + while(d) { + forCellIdEx(cc, i, c1) { + int d1 = celldistance(cc, c2); + if(d1 < d) { + t = t * cellrelmatrix(c1, i); + c1 = cc; + d = d1; + goto again; + } } + printf("ERROR not reached\n"); + break; + again: ; } - if(d != 0) printf("ERROR not reached\n"); - if(mirrors&1) t = Mirror * t * Mirror; - if(whateveri) printf(" => %p\n", c1); return t; }