From 69af3ee4e378716cf4c022e3351e3b9fd1c7ab7a Mon Sep 17 00:00:00 2001 From: Zeno Rogue Date: Thu, 8 Dec 2022 22:06:44 +0100 Subject: [PATCH] embedded_plane:: safer pushing --- hyperpoint.cpp | 31 ++++++++++++++++--------------- 1 file changed, 16 insertions(+), 15 deletions(-) diff --git a/hyperpoint.cpp b/hyperpoint.cpp index 1431665e..57b1db7e 100644 --- a/hyperpoint.cpp +++ b/hyperpoint.cpp @@ -745,7 +745,7 @@ EX transmatrix cmirror(int cid) { EX transmatrix xpush(ld alpha) { return cpush(0, alpha); } EX transmatrix lxpush(ld alpha) { - if(WDIM == 2 && GDIM == 3) { + if(embedded_plane) { geom3::light_flip(true); auto t = cpush(0, alpha); geom3::light_flip(false); @@ -1601,12 +1601,13 @@ EX transmatrix transpose(transmatrix T) { } EX hyperpoint lspinpush0(ld alpha, ld x) { - geom3::light_flip(true); + bool f = embedded_plane; + if(f) geom3::light_flip(true); + if(embedded_plane) throw hr_exception("still embedded plane"); hyperpoint h = xspinpush0(alpha, x); - geom3::light_flip(false); - swapmatrix(h); + if(f) geom3::light_flip(false); + if(f) swapmatrix(h); return h; - // return spin(alpha) * lxpush(x) * C0; } #if HDR @@ -1627,16 +1628,6 @@ inline hyperpoint cpush0(int c, ld x) { return h; } -inline hyperpoint xspinpush0(ld alpha, ld x) { - if(sl2) return slr::polar(x, -alpha, 0); - if(embedded_plane) return lspinpush0(alpha, x); - hyperpoint h = Hypc; - h[LDIM] = cos_auto(x); - h[0] = sin_auto(x) * cos(alpha); - h[1] = sin_auto(x) * -sin(alpha); - return h; - } - inline hyperpoint xpush0(ld x) { return cpush0(0, x); } inline hyperpoint lxpush0(ld x) { return lxpush(x) * tile_center(); } inline hyperpoint ypush0(ld x) { return cpush0(1, x); } @@ -1656,6 +1647,16 @@ inline shiftpoint tC0(const shiftmatrix &T) { } #endif +EX hyperpoint xspinpush0(ld alpha, ld x) { + if(sl2) return slr::polar(x, -alpha, 0); + if(embedded_plane) return lspinpush0(alpha, x); + hyperpoint h = Hypc; + h[LDIM] = cos_auto(x); + h[0] = sin_auto(x) * cos(alpha); + h[1] = sin_auto(x) * -sin(alpha); + return h; + } + /** tangent vector in the given direction */ EX hyperpoint ctangent(int c, ld x) { return point3(c==0?x:0, c==1?x:0, c==2?x:0); }