diff --git a/drawing.cpp b/drawing.cpp index 37d180b1..036b21bd 100644 --- a/drawing.cpp +++ b/drawing.cpp @@ -488,8 +488,10 @@ bool behind3(shiftpoint h) { return lp_apply(inverse_exp(h))[2] < 0; if(pmodel == mdLiePerspective) return lp_apply(lie_log(h))[2] < 0; + #if MAXMDIM >= 4 if(pmodel == mdRelPerspective) return lp_apply(rel_log(h, false))[2] < 0; + #endif return h[2] < 0; } diff --git a/hyperpoint.cpp b/hyperpoint.cpp index 48f22611..4161173c 100644 --- a/hyperpoint.cpp +++ b/hyperpoint.cpp @@ -459,7 +459,7 @@ EX transmatrix to_other_side(hyperpoint h1, hyperpoint h2) { h1 = normalize(h1); h2 = normalize(h2); transmatrix T = to_other_side(h1, h2); - for(int i=0; i<4; i++) T[i][3] = T[3][i] = i == 3; + fix4(T); geom3::light_flip(false); return T; } @@ -487,7 +487,9 @@ EX transmatrix to_other_side(hyperpoint h1, hyperpoint h2) { EX ld material(const hyperpoint& h) { if(sphere || in_s2xe()) return intval(h, Hypc); else if(hyperbolic || in_h2xe()) return -intval(h, Hypc); + #if MAXMDIM >= 4 else if(sl2) return h[2]*h[2] + h[3]*h[3] - h[0]*h[0] - h[1]*h[1]; + #endif else return h[LDIM]; } @@ -790,8 +792,12 @@ EX transmatrix parabolic13(ld u, ld v) { } EX hyperpoint kleinize(hyperpoint h) { + #if MAXMDIM == 3 + return point3(h[0]/h[2], h[1]/h[2], 1); + #else if(GDIM == 2) return point3(h[0]/h[2], h[1]/h[2], 1); else return point31(h[0]/h[3], h[1]/h[3], h[2]/h[3]); + #endif } EX hyperpoint deparabolic13(hyperpoint h) { @@ -1316,7 +1322,9 @@ EX shiftmatrix orthogonal_move(const shiftmatrix& t, double level) { /** fix a 3x3 matrix into a 4x4 matrix */ EX transmatrix fix4(transmatrix t) { + #if MAXMDIM > 3 for(int i=0; i<4; i++) t[3][i] = t[i][3] = i == 3; + #endif return t; } @@ -1379,6 +1387,7 @@ EX hyperpoint mid_at_actual(hyperpoint h, ld v) { return rspintox(h) * xpush0(hdist0(h) * v); } +#if MAXMDIM >= 4 /** in 3D, an orthogonal projection of C0 on the given triangle */ EX hyperpoint orthogonal_of_C0(hyperpoint h0, hyperpoint h1, hyperpoint h2) { h0 /= h0[3]; @@ -1393,6 +1402,7 @@ EX hyperpoint orthogonal_of_C0(hyperpoint h0, hyperpoint h1, hyperpoint h2) { hyperpoint h = w * denom + d1 * a1 + d2 * a2; return normalize(h); } +#endif EX hyperpoint hpxd(ld d, ld x, ld y, ld z) { hyperpoint H = hpxyz(d*x, d*y, z); @@ -1800,6 +1810,7 @@ EX ld inner3(hyperpoint h1, hyperpoint h2) { h1[0] * h2[0] + h1[1] * h2[1]; } +#if MAXMDIM >= 4 /** circumscribe for H3 and S3 (not for E3 yet!) */ EX hyperpoint circumscribe(hyperpoint a, hyperpoint b, hyperpoint c, hyperpoint d) { @@ -1829,6 +1840,7 @@ EX hyperpoint circumscribe(hyperpoint a, hyperpoint b, hyperpoint c, hyperpoint return h; } +#endif /** the point in distance dist from 'material' to 'dir' (usually an (ultra)ideal point) */ EX hyperpoint towards_inf(hyperpoint material, hyperpoint dir, ld dist IS(1)) { diff --git a/hypgraph.cpp b/hypgraph.cpp index 72a0c9d0..ea132ee2 100644 --- a/hypgraph.cpp +++ b/hypgraph.cpp @@ -642,7 +642,9 @@ EX void apply_other_model(shiftpoint H_orig, hyperpoint& ret, eModel md) { /* x wanes as z grows! */ } hyperpoint S = lie_log_correct(H_orig, H); + #if MAXMDIM >= 4 S[3] = 1; + #endif S = lp_apply(S); if(hyperbolic) { models::apply_orientation(ret[1], ret[0]); @@ -652,12 +654,14 @@ EX void apply_other_model(shiftpoint H_orig, hyperpoint& ret, eModel md) { return; } + #if MAXMDIM >= 4 case mdRelPerspective: { auto S = rel_log(H_orig, true); S[3] = 1; S = lp_apply(S); apply_perspective(S, ret); return; } + #endif case mdPixel: ret = H / current_display->radius; @@ -912,6 +916,7 @@ EX void apply_other_model(shiftpoint H_orig, hyperpoint& ret, eModel md) { break; } + #if MAXMDIM >= 4 case mdRelOrthogonal: { ret = rel_log(H_orig, true); @@ -921,6 +926,7 @@ EX void apply_other_model(shiftpoint H_orig, hyperpoint& ret, eModel md) { if(!vrhr::rendering()) ret = lp_apply(ret); break; } + #endif case mdHemisphere: { @@ -2542,6 +2548,7 @@ EX void draw_model_elements() { dynamicval lw(vid.linewidth, vid.linewidth * vid.multiplier_ring); switch(pmodel) { + #if MAXMDIM >= 4 case mdRelOrthogonal: case mdRelPerspective: { constexpr ld cc = 3; @@ -2565,6 +2572,7 @@ EX void draw_model_elements() { } return; } + #endif case mdRotatedHyperboles: { queuestr(current_display->xcenter, current_display->ycenter + current_display->radius * pconf.alpha, 0, vid.fsize, "X", ringcolor, 1, 8); @@ -3299,6 +3307,7 @@ EX shiftpoint lie_exp(hyperpoint h1) { /** Compute the Lie logarithm in SL(2,R), which corresponds to a geodesic in AdS; or a geodesic in de Sitter space. **/ +#if MAXMDIM >= 4 EX hyperpoint rel_log(shiftpoint h, bool relativistic_length) { if(sl2) { optimize_shift(h); @@ -3341,6 +3350,7 @@ EX hyperpoint rel_log(shiftpoint h, bool relativistic_length) { } throw hr_exception("rel_log in wrong geometry"); } +#endif /** Is Lie movement available? Depends on map geometry, not ambient geometry. */ EX bool lie_movement_available() { @@ -3351,7 +3361,9 @@ EX bool lie_movement_available() { EX hyperpoint lie_log(const shiftpoint h1) { hyperpoint h = unshift(h1); - if(nil) { + if(0) ; + #if MAXMDIM >= 4 + else if(nil) { h[3] = 0; h[2] -= h[0] * h[1] / 2; } @@ -3380,6 +3392,10 @@ EX hyperpoint lie_log(const shiftpoint h1) { h[1] *= z / (exp(+z) - 1); } } + else if(sl2) { + return rel_log(h1, false); + } + #endif else if(euclid) { h[LDIM] = 0; } @@ -3389,9 +3405,6 @@ EX hyperpoint lie_log(const shiftpoint h1) { for(int i=1; i= 4 return acd_bin(h[0]) + acd_bin(h[1]) * sY + acd_bin(h[2]) * sZ + acd_bin(h[3]) * sT; + #else + return 0; + #endif } } return 0;