1
0
mirror of https://github.com/zenorogue/hyperrogue.git synced 2024-12-27 10:30:36 +00:00

fixed camera movement in ESL2

This commit is contained in:
Zeno Rogue 2023-01-07 19:41:42 +01:00
parent f02073a35f
commit 8136d9b554
2 changed files with 7 additions and 11 deletions

View File

@ -588,7 +588,7 @@ EX hyperpoint esl2_ati(hyperpoint h) {
ld S = sqrt(U) * (a1 > 0 ? 1 : -1); ld S = sqrt(U) * (a1 > 0 ? 1 : -1);
ld x = -asinh(S); ld x = -asinh(S);
h = lorentz(0, 3, -x) * lorentz(1, 2, x) * h; h = lorentz(0, 3, -x) * lorentz(1, 2, x) * h;
ld y = h[3] ? atanh(h[1] / h[3]) : atanh(h[0] / h[2]); ld y = h[3]*h[3] > h[2]*h[2] ? atanh(h[1] / h[3]) : atanh(h[0] / h[2]);
h = lorentz(0, 2, -y) * lorentz(1, 3, -y) * h; h = lorentz(0, 2, -y) * lorentz(1, 3, -y) * h;
ld z = atan2(h[2], h[3]); ld z = atan2(h[2], h[3]);
return hyperpoint(x, y, z, 0); return hyperpoint(x, y, z, 0);

View File

@ -3293,6 +3293,9 @@ EX transmatrix get_shift_view_of(const hyperpoint H, const transmatrix V, eShift
} }
case smGeodesic: case smGeodesic:
return iview_inverse(nisot::parallel_transport(view_inverse(V), -H)); return iview_inverse(nisot::parallel_transport(view_inverse(V), -H));
case smESL2: {
return get_shift_view_embedded_of_esl2(V, esl2_ita0(lp_iapply(-H)));
}
default: default:
throw hr_exception("unknown shift method (embedded not supported)"); throw hr_exception("unknown shift method (embedded not supported)");
} }
@ -3338,14 +3341,7 @@ EX transmatrix get_shift_view_embedded_of_esl2(const transmatrix V, const hyperp
transmatrix V1 = gpushxto0(h) * gpushxto0(IV*C0); transmatrix V1 = gpushxto0(h) * gpushxto0(IV*C0);
transmatrix IV1 = view_inverse(V1); transmatrix IV1 = view_inverse(V1);
transmatrix rot1 = V1 * map_relative_push(IV1 * C0); transmatrix rot1 = V1 * map_relative_push(IV1 * C0);
return rot * inverse(rot1) * V1 * inverse(V); return rot * inverse(rot1) * V1;
}
void shift_view_esl2(hyperpoint h) {
transmatrix R = get_shift_view_embedded_of_esl2(View, h);
View = R * View;
auto& wc = current_display->which_copy;
wc = R * wc;
} }
/** works in isotropic and product spaces */ /** works in isotropic and product spaces */
@ -3419,7 +3415,7 @@ EX void shift_view_to(shiftpoint H, eShiftMethod sm IS(shift_method(smaManualCam
shift_view_by_matrix(gpushxto0(unshift(H)), sm); shift_view_by_matrix(gpushxto0(unshift(H)), sm);
return; return;
case smESL2: case smESL2:
shift_view_esl2(lp_iapply(unshift(H))); shift_view(-lp_apply(esl2_ati(lp_iapply(unshift(H)))), sm);
return; return;
case smLie: case smLie:
shift_view(-lie_log(H), sm); shift_view(-lie_log(H), sm);
@ -3439,7 +3435,7 @@ EX void shift_view_towards(shiftpoint H, ld l, eShiftMethod sm IS(shift_method(s
shift_view_by_matrix(rspintox(unshift(H)) * xpush(-l) * spintox(unshift(H)), sm); shift_view_by_matrix(rspintox(unshift(H)) * xpush(-l) * spintox(unshift(H)), sm);
return; return;
case smESL2: case smESL2:
shift_view_esl2(esl2_ita0(tangent_length(esl2_ati(lp_iapply(unshift(H))), l))); shift_view(-lp_apply(tangent_length(esl2_ati(lp_iapply(unshift(H))), l)));
return; return;
case smLie: case smLie:
shift_view(tangent_length(lie_log(H), -l), sm); shift_view(tangent_length(lie_log(H), -l), sm);