function 'relative_matrix_recursive' for reg3_rule and arbi

This commit is contained in:
Zeno Rogue 2020-01-28 11:22:49 +01:00
parent 370cdafaf8
commit 3df5eff7f8
3 changed files with 32 additions and 30 deletions

View File

@ -444,32 +444,7 @@ struct hrmap_arbi : hrmap {
}
transmatrix relative_matrix(heptagon *h2, heptagon *h1, const hyperpoint& hint) override {
if(gmatrix0.count(h2->c7) && gmatrix0.count(h1->c7))
return inverse(gmatrix0[h1->c7]) * gmatrix0[h2->c7];
transmatrix gm = Id, where = Id;
while(h1 != h2) {
for(int i=0; i<h1->type; i++) {
if(h1->move(i) == h2) {
return gm * adj(h1, i) * where;
}
}
if(h1->distance > h2->distance) {
for(int i=0; i<h1->type; i++) if(h1->move(i) && h1->move(i)->distance < h1->distance) {
gm = gm * adj(h1, i);
h1 = h1->move(i);
goto again;
}
}
else {
for(int i=0; i<h2->type; i++) if(h2->move(i) && h2->move(i)->distance < h2->distance) {
where = iadj(h2, 0) * where;
h2 = h2->move(i);
goto again;
}
}
again: ;
}
return gm * where;
return relative_matrix_recursive(h2, h1);
}
transmatrix adj(cell *c, int dir) override { return adj(c->master, dir); }

View File

@ -22,6 +22,36 @@ EX void fixelliptic(hyperpoint& h) {
for(int i=0; i<MDIM; i++) h[i] = -h[i];
}
/** find relative_matrix via recursing the tree structure */
EX transmatrix relative_matrix_recursive(heptagon *h2, heptagon *h1) {
if(gmatrix0.count(h2->c7) && gmatrix0.count(h1->c7))
return inverse(gmatrix0[h1->c7]) * gmatrix0[h2->c7];
transmatrix gm = Id, where = Id;
while(h1 != h2) {
for(int i=0; i<h1->type; i++) {
if(h1->move(i) == h2) {
return gm * currentmap->adj(h1, i) * where;
}
}
if(h1->distance > h2->distance) {
for(int i=0; i<h1->type; i++) if(h1->move(i) && h1->move(i)->distance < h1->distance) {
gm = gm * currentmap->adj(h1, i);
h1 = h1->move(i);
goto again;
}
}
else {
for(int i=0; i<h2->type; i++) if(h2->move(i) && h2->move(i)->distance < h2->distance) {
where = currentmap->iadj(h2, 0) * where;
h2 = h2->move(i);
goto again;
}
}
again: ;
}
return gm * where;
}
EX transmatrix master_relative(cell *c, bool get_inverse IS(false)) {
if(0) ;
#if CAP_IRR

View File

@ -1115,10 +1115,7 @@ EX namespace reg3 {
}
transmatrix relative_matrix(heptagon *h2, heptagon *h1, const hyperpoint& hint) override {
if(gmatrix0.count(h2->c7) && gmatrix0.count(h1->c7))
return inverse(gmatrix0[h1->c7]) * gmatrix0[h2->c7];
println(hlog, "unknown");
return Id;
return relative_matrix_recursive(h2, h1);
}
vector<hyperpoint> get_vertices(cell* c) override {