From 3f2a84be5fa7a71e95e582f59b8ed51b56f95fe2 Mon Sep 17 00:00:00 2001 From: Zeno Rogue Date: Sat, 7 Jan 2023 11:45:40 +0100 Subject: [PATCH] refactored get_logical_z --- graph.cpp | 9 ++------- hyperpoint.cpp | 19 +++++++++++++++++++ 2 files changed, 21 insertions(+), 7 deletions(-) diff --git a/graph.cpp b/graph.cpp index 52e6c3f5..ef06d857 100644 --- a/graph.cpp +++ b/graph.cpp @@ -5077,13 +5077,8 @@ EX void make_actual_view() { actual_view_transform = get_shift_view_of(ztangent(d), actual_view_transform * View) * view_inverse(View); } hyperpoint h = tC0(view_inverse(actual_view_transform * View)); - - if(geom3::euc_in_nil()) camera_level = h[1]; - else if(geom3::euc_in_solnih()) camera_level = h[2]; - else if(geom3::hyp_in_solnih()) camera_level = h[0]; - else if(gproduct) camera_level = log(h[2]); - else camera_level = asin_auto(h[2]); - if(moved_center()) camera_level--; + + camera_level = get_logical_z(h); camera_sign = cgi.FLOOR > cgi.WALL; } diff --git a/hyperpoint.cpp b/hyperpoint.cpp index 74901fc1..4c635f62 100644 --- a/hyperpoint.cpp +++ b/hyperpoint.cpp @@ -930,6 +930,25 @@ EX hyperpoint orthogonal_move(const hyperpoint& h, ld z) { u *= cos_auto(z); return hpxy3(h[0] * u, h[1] * u, sinh(z)); } + +EX ld get_logical_z(hyperpoint h) { + if(geom3::euc_in_nil()) + return h[1]; + if(geom3::euc_in_solnih()) + return h[2]; + if(geom3::hyp_in_solnih()) + return h[0]; + if(geom3::euc_in_sl2()) + return esl2_ati(h)[1]; + if(geom3::euc_in_product()) { + ld bz = zlevel(h); + auto h1 = h / exp(bz); + return asin_auto(h1[1]); + } + if(gproduct) + return log(h[2]); + return asin_auto(h[2]) - (moved_center() ? 1 : 0); + } #endif // push alpha units vertically