From b7a4997509d8de82a5b5389841371f3187416769 Mon Sep 17 00:00:00 2001 From: Zeno Rogue Date: Sat, 7 Jan 2023 12:22:14 +0100 Subject: [PATCH] fixed camera movement in euc_in_sl2 --- hyperpoint.cpp | 4 ++-- hypgraph.cpp | 25 +++++++++++++++++++++++-- 2 files changed, 25 insertions(+), 4 deletions(-) diff --git a/hyperpoint.cpp b/hyperpoint.cpp index 4c635f62..453957a8 100644 --- a/hyperpoint.cpp +++ b/hyperpoint.cpp @@ -1765,7 +1765,7 @@ EX bool asign(ld y1, ld y2) { return signum(y1) != signum(y2); } EX ld xcross(ld x1, ld y1, ld x2, ld y2) { return x1 + (x2 - x1) * y1 / (y1 - y2); } #if HDR -enum eShiftMethod { smProduct, smIsotropic, smEmbedded, smLie, smGeodesic }; +enum eShiftMethod { smProduct, smIsotropic, smEmbedded, smLie, smGeodesic, smESL2 }; enum eEmbeddedShiftMethodChoice { smcNone, smcBoth, smcAuto }; enum eShiftMethodApplication { smaManualCamera, smaAutocenter, smaObject, smaWallRadar }; #endif @@ -1785,7 +1785,7 @@ EX bool use_embedded_shift(eShiftMethodApplication sma) { EX eShiftMethod shift_method(eShiftMethodApplication sma) { if(gproduct) return smProduct; if(embedded_plane && sma == smaObject) return geom3::same_in_same() ? smIsotropic : smEmbedded; - if(embedded_plane && use_embedded_shift(sma)) return (nonisotropic && !sl2) ? smLie : smEmbedded; + if(embedded_plane && use_embedded_shift(sma)) return sl2 ? smESL2 : nonisotropic ? smLie : smEmbedded; if(!nonisotropic && !stretch::in() && !(!nisot::geodesic_movement && hyperbolic && bt::in())) return smIsotropic; if(!nisot::geodesic_movement && !embedded_plane) return smLie; return smGeodesic; diff --git a/hypgraph.cpp b/hypgraph.cpp index b9e1c725..ec8496b2 100644 --- a/hypgraph.cpp +++ b/hypgraph.cpp @@ -3306,7 +3306,7 @@ EX void shift_view(hyperpoint H, eShiftMethod sm IS(shift_method(smaManualCamera wc = get_shift_view_of(H, wc, sm); } -/** works in embedded_plane (except embedded product where shift_view works) */ +/** works in embedded_plane (except embedded product where shift_view works, and euc_in_sl2) */ EX transmatrix get_shift_view_embedded_of(const transmatrix V, const transmatrix T) { transmatrix IV = view_inverse(V); transmatrix rot = V * map_relative_push(IV * C0); @@ -3324,6 +3324,22 @@ void shift_view_embedded(const transmatrix T) { wc = R * wc; } +EX transmatrix get_shift_view_embedded_of_esl2(const transmatrix V, const hyperpoint h) { + transmatrix IV = view_inverse(V); + transmatrix rot = V * map_relative_push(IV * C0); + transmatrix V1 = gpushxto0(h) * gpushxto0(IV*C0); + transmatrix IV1 = view_inverse(V1); + transmatrix rot1 = V1 * map_relative_push(IV1 * C0); + return rot * inverse(rot1) * V1 * inverse(V); + } + +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 */ void shift_view_mmul(const transmatrix T) { View = T * View; @@ -3394,6 +3410,9 @@ EX void shift_view_to(shiftpoint H, eShiftMethod sm IS(shift_method(smaManualCam case smProduct: shift_view_by_matrix(gpushxto0(unshift(H)), sm); return; + case smESL2: + shift_view_esl2(lp_iapply(unshift(H))); + return; case smLie: shift_view(-lie_log(H), sm); return; @@ -3409,9 +3428,11 @@ EX void shift_view_towards(shiftpoint H, ld l, eShiftMethod sm IS(shift_method(s switch(sm) { case smIsotropic: case smEmbedded: - if(sl2) shift_view_to(H, sm); // shift_view_by_matrix(rgpushxto0(unshift(lie_exp(tangent_length(lie_log(H), -l)))), smEmbedded); shift_view_by_matrix(rspintox(unshift(H)) * xpush(-l) * spintox(unshift(H)), sm); return; + case smESL2: + shift_view_esl2(esl2_ita0(tangent_length(esl2_ati(lp_iapply(unshift(H))), l))); + return; case smLie: shift_view(tangent_length(lie_log(H), -l), sm); return;