From 2acc86695834e8ed716aae95c1233dd192b36dcb Mon Sep 17 00:00:00 2001 From: Zeno Rogue Date: Sat, 24 Aug 2019 20:29:32 +0200 Subject: [PATCH] slr:: virtualRebase --- geometry2.cpp | 45 ++++++++++++++++++++++++++++----------------- 1 file changed, 28 insertions(+), 17 deletions(-) diff --git a/geometry2.cpp b/geometry2.cpp index ed120738..1c08b97c 100644 --- a/geometry2.cpp +++ b/geometry2.cpp @@ -244,6 +244,28 @@ struct horo_distance { } }; +template +void virtualRebase_cell(cell*& base, T& at, const U& check) { + horo_distance currz(check(at)); + T best_at = at; + while(true) { + cell *newbase = NULL; + forCellCM(c2, base) { + transmatrix V2 = calc_relative_matrix(base, c2, C0); + T cand_at = V2 * at; + horo_distance newz(check(cand_at)); + if(newz < currz) { + currz = newz; + best_at = cand_at; + newbase = c2; + } + } + if(!newbase) break; + base = newbase; + at = best_at; + } + } + template void virtualRebase(cell*& base, T& at, bool tohex, const U& check) { if(prod) { @@ -257,6 +279,10 @@ void virtualRebase(cell*& base, T& at, bool tohex, const U& check) { base = hybrid::get_at(w.first, w.second); return; } + if(sl2) { + virtualRebase_cell(base, at, check); + return; + } if((euclid || sphere) && WDIM == 2) { again: if(euwrap) for(int i=0; i<6; i++) { @@ -326,23 +352,8 @@ void virtualRebase(cell*& base, T& at, bool tohex, const U& check) { at = bestV * at; } else at = master_relative(base, true) * at; - if(binarytiling || (tohex && (GOLDBERG || IRREGULAR)) || WDIM == 3 || penrose) { - while(true) { - newbase = NULL; - forCellCM(c2, base) { - transmatrix V2 = calc_relative_matrix(base, c2, C0); - horo_distance newz(check(V2 * at)); - if(newz < currz) { - currz = newz; - bestV = V2; - newbase = c2; - } - } - if(!newbase) break; - base = newbase; - at = bestV * at; - } - } + if(binarytiling || (tohex && (GOLDBERG || IRREGULAR)) || WDIM == 3 || penrose) + virtualRebase_cell(base, at, check); break; } }