1
0
mirror of https://github.com/zenorogue/hyperrogue.git synced 2024-12-25 01:20:37 +00:00

ads:: since the implementations of nmul/ninverse have been moved to twist::, do not duplicate them

This commit is contained in:
Zeno Rogue 2024-07-17 11:27:31 +02:00
parent e881812fa4
commit c326600f52

View File

@ -15,8 +15,8 @@ struct ads_point : shiftpoint {
/** similarly, ads_matrix represents a transformation of the universal cover space */ /** similarly, ads_matrix represents a transformation of the universal cover space */
struct ads_matrix : shiftmatrix { struct ads_matrix : shiftmatrix {
ads_matrix(transmatrix _h = Id, ld _s = 0) { T = _h; shift = _s; } ads_matrix(transmatrix _h = Id, ld _s = 0) { T = _h; shift = _s; }
ads_point operator* (ads_point) const; ads_point operator* (const ads_point&) const;
ads_matrix operator* (ads_matrix) const; ads_matrix operator* (const ads_matrix&) const;
ads_point operator* (const hyperpoint& h) const { return ads_point(T*h, shift); } ads_point operator* (const hyperpoint& h) const { return ads_point(T*h, shift); }
ads_matrix operator* (const transmatrix& h) const { return ads_matrix(T*h, shift); } ads_matrix operator* (const transmatrix& h) const { return ads_matrix(T*h, shift); }
ads_matrix(shiftmatrix _s) : shiftmatrix(_s) {} ads_matrix(shiftmatrix _s) : shiftmatrix(_s) {}
@ -61,47 +61,16 @@ transmatrix chg_shift(ld x) {
return cspin(2, 3, x) * cspin(0, 1, x); return cspin(2, 3, x) * cspin(0, 1, x);
} }
ads_point ads_matrix::operator*(ads_point h) const { ads_point ads_matrix::operator*(const ads_point& h) const {
auto& T = *this; return ads_point(twist::nmul(self, h));
optimize_shift(h);
ld sh = get_shift_cycles(h.shift);
h.shift -= sh;
auto res0 = T;
optimize_shift(res0);
auto res1 = res0 * chg_shift(h.shift);
optimize_shift(res1);
res1.shift += get_shift_cycles(res0.shift - res1.shift);
auto res2 = res1 * h.h;
optimize_shift(res2);
res2.shift += get_shift_cycles(res1.shift - res2.shift);
res2.shift += sh;
return res2;
} }
ads_matrix ads_matrix::operator*(ads_matrix h) const { ads_matrix ads_matrix::operator*(const ads_matrix& h) const {
auto& T = *this; return ads_matrix(twist::nmul(self, h));
optimize_shift(h);
ld sh = get_shift_cycles(h.shift);
h.shift -= sh;
auto res0 = T;
optimize_shift(res0);
auto res1 = res0 * chg_shift(h.shift);
optimize_shift(res1);
res1.shift += get_shift_cycles(res0.shift - res1.shift);
auto res2 = res1 * h.T;
optimize_shift(res2);
res2.shift += get_shift_cycles(res1.shift - res2.shift);
res2.shift += sh;
return res2;
} }
ads_matrix ads_inverse(const ads_matrix& T) { ads_matrix ads_inverse(const ads_matrix& T) {
ads_matrix res(inverse(unshift(T)), 0); return ads_matrix(twist::ninverse(T));
ads_matrix m = res * T;
optimize_shift(m);
res.shift -= m.shift;
return res;
} }
struct cross_result { struct cross_result {