1
0
mirror of https://github.com/zenorogue/hyperrogue.git synced 2024-09-19 18:29:36 +00:00

twist:: nil implemented using uxpush/uypush/uzpush instead of special cases

This commit is contained in:
Zeno Rogue 2024-06-16 23:40:18 +02:00
parent 144c76ca8b
commit 8b7d7d56e9

View File

@ -1623,7 +1623,6 @@ EX namespace hybrid {
tf = hdist0(hm)/2; tf = hdist0(hm)/2;
alpha = atan2(hm[1], hm[0]); alpha = atan2(hm[1], hm[0]);
}); });
if(nil) return spin(-alpha) * xpush(tf*2) * ypush(-he*2) * zpush(lev) * C0;
return spin(alpha) * twist::uxpush(tf) * twist::uypush(he) * twist::uzpush(lev) * C0; return spin(alpha) * twist::uxpush(tf) * twist::uypush(he) * twist::uzpush(lev) * C0;
#else #else
throw hr_exception(); throw hr_exception();
@ -2349,30 +2348,23 @@ EX namespace twist {
#if MAXMDIM >= 4 #if MAXMDIM >= 4
EX transmatrix uxpush(ld x) { EX transmatrix uxpush(ld x) {
if(sl2) return xpush(x); if(sl2) return xpush(x);
if(nil) return xpush(x*2);
return cspin(1, 3, x) * cspin(0, 2, x); return cspin(1, 3, x) * cspin(0, 2, x);
} }
EX transmatrix uypush(ld y) { EX transmatrix uypush(ld y) {
if(sl2) return ypush(y); if(sl2) return ypush(y);
if(nil) return ypush(y*2);
return cspin(0, 3, -y) * cspin(1, 2, y); return cspin(0, 3, -y) * cspin(1, 2, y);
} }
EX transmatrix uzpush(ld z) { EX transmatrix uzpush(ld z) {
if(sl2) return zpush(z); if(sl2) return zpush(z);
if(nil) return zpush(z) * spin(-2*z);
return cspin(3, 2, -z) * cspin(0, 1, -z); return cspin(3, 2, -z) * cspin(0, 1, -z);
} }
EX transmatrix lift_matrix(const transmatrix& T) { EX transmatrix lift_matrix(const transmatrix& T) {
if(nil) {
ld alpha;
hybrid::in_underlying_geometry([&] {
hyperpoint h = tC0(T);
transmatrix Spin = iso_inverse(gpushxto0(h) * T);
alpha = atan2(Spin[0][1], Spin[0][0]);
});
hyperpoint h(T[0][2], T[1][2], 0, 1);
return nisot::translate(h) * spin(-alpha);
}
hyperpoint d; hyperpoint d;
ld alpha, beta, distance; ld alpha, beta, distance;
transmatrix Spin; transmatrix Spin;
@ -2395,8 +2387,6 @@ EX namespace twist {
std::map<int, transmatrix> saved_matrices; std::map<int, transmatrix> saved_matrices;
transmatrix adj(cell *c1, int i) override { transmatrix adj(cell *c1, int i) override {
if(nil && i == c1->type-2) return zpush(-cgi.plevel);
if(nil && i == c1->type-1) return zpush(+cgi.plevel);
if(i == c1->type-2) return uzpush(-cgi.plevel) * spin(-2*cgi.plevel); if(i == c1->type-2) return uzpush(-cgi.plevel) * spin(-2*cgi.plevel);
if(i == c1->type-1) return uzpush(+cgi.plevel) * spin(+2*cgi.plevel); if(i == c1->type-1) return uzpush(+cgi.plevel) * spin(+2*cgi.plevel);
cell *c2 = c1->cmove(i); cell *c2 = c1->cmove(i);
@ -2425,8 +2415,6 @@ EX namespace twist {
} }
transmatrix ray_iadj(cell *c1, int i) override { transmatrix ray_iadj(cell *c1, int i) override {
if(nil && i == c1->type-2) return zpush(-cgi.plevel);
if(nil && i == c1->type-1) return zpush(+cgi.plevel);
if(i == c1->type-1) return uzpush(-cgi.plevel) * spin(-2*cgi.plevel); if(i == c1->type-1) return uzpush(-cgi.plevel) * spin(-2*cgi.plevel);
if(i == c1->type-2) return uzpush(+cgi.plevel) * spin(+2*cgi.plevel); if(i == c1->type-2) return uzpush(+cgi.plevel) * spin(+2*cgi.plevel);
cell *c2 = c1->cmove(i); cell *c2 = c1->cmove(i);