mirror of
https://github.com/zenorogue/hyperrogue.git
synced 2025-08-04 04:43:57 +00:00
added MAXMDIM guards in various places
This commit is contained in:
parent
804c3897b8
commit
e63feddb7c
@ -488,8 +488,10 @@ bool behind3(shiftpoint h) {
|
|||||||
return lp_apply(inverse_exp(h))[2] < 0;
|
return lp_apply(inverse_exp(h))[2] < 0;
|
||||||
if(pmodel == mdLiePerspective)
|
if(pmodel == mdLiePerspective)
|
||||||
return lp_apply(lie_log(h))[2] < 0;
|
return lp_apply(lie_log(h))[2] < 0;
|
||||||
|
#if MAXMDIM >= 4
|
||||||
if(pmodel == mdRelPerspective)
|
if(pmodel == mdRelPerspective)
|
||||||
return lp_apply(rel_log(h, false))[2] < 0;
|
return lp_apply(rel_log(h, false))[2] < 0;
|
||||||
|
#endif
|
||||||
return h[2] < 0;
|
return h[2] < 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -459,7 +459,7 @@ EX transmatrix to_other_side(hyperpoint h1, hyperpoint h2) {
|
|||||||
h1 = normalize(h1);
|
h1 = normalize(h1);
|
||||||
h2 = normalize(h2);
|
h2 = normalize(h2);
|
||||||
transmatrix T = to_other_side(h1, 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);
|
geom3::light_flip(false);
|
||||||
return T;
|
return T;
|
||||||
}
|
}
|
||||||
@ -487,7 +487,9 @@ EX transmatrix to_other_side(hyperpoint h1, hyperpoint h2) {
|
|||||||
EX ld material(const hyperpoint& h) {
|
EX ld material(const hyperpoint& h) {
|
||||||
if(sphere || in_s2xe()) return intval(h, Hypc);
|
if(sphere || in_s2xe()) return intval(h, Hypc);
|
||||||
else if(hyperbolic || in_h2xe()) 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];
|
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];
|
else return h[LDIM];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -790,8 +792,12 @@ EX transmatrix parabolic13(ld u, ld v) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
EX hyperpoint kleinize(hyperpoint h) {
|
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);
|
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]);
|
else return point31(h[0]/h[3], h[1]/h[3], h[2]/h[3]);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
EX hyperpoint deparabolic13(hyperpoint h) {
|
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 */
|
/** fix a 3x3 matrix into a 4x4 matrix */
|
||||||
EX transmatrix fix4(transmatrix t) {
|
EX transmatrix fix4(transmatrix t) {
|
||||||
|
#if MAXMDIM > 3
|
||||||
for(int i=0; i<4; i++) t[3][i] = t[i][3] = i == 3;
|
for(int i=0; i<4; i++) t[3][i] = t[i][3] = i == 3;
|
||||||
|
#endif
|
||||||
return t;
|
return t;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1379,6 +1387,7 @@ EX hyperpoint mid_at_actual(hyperpoint h, ld v) {
|
|||||||
return rspintox(h) * xpush0(hdist0(h) * v);
|
return rspintox(h) * xpush0(hdist0(h) * v);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if MAXMDIM >= 4
|
||||||
/** in 3D, an orthogonal projection of C0 on the given triangle */
|
/** in 3D, an orthogonal projection of C0 on the given triangle */
|
||||||
EX hyperpoint orthogonal_of_C0(hyperpoint h0, hyperpoint h1, hyperpoint h2) {
|
EX hyperpoint orthogonal_of_C0(hyperpoint h0, hyperpoint h1, hyperpoint h2) {
|
||||||
h0 /= h0[3];
|
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;
|
hyperpoint h = w * denom + d1 * a1 + d2 * a2;
|
||||||
return normalize(h);
|
return normalize(h);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
EX hyperpoint hpxd(ld d, ld x, ld y, ld z) {
|
EX hyperpoint hpxd(ld d, ld x, ld y, ld z) {
|
||||||
hyperpoint H = hpxyz(d*x, d*y, 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];
|
h1[0] * h2[0] + h1[1] * h2[1];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if MAXMDIM >= 4
|
||||||
/** circumscribe for H3 and S3 (not for E3 yet!) */
|
/** circumscribe for H3 and S3 (not for E3 yet!) */
|
||||||
EX hyperpoint circumscribe(hyperpoint a, hyperpoint b, hyperpoint c, hyperpoint d) {
|
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;
|
return h;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
/** the point in distance dist from 'material' to 'dir' (usually an (ultra)ideal point) */
|
/** 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)) {
|
EX hyperpoint towards_inf(hyperpoint material, hyperpoint dir, ld dist IS(1)) {
|
||||||
|
21
hypgraph.cpp
21
hypgraph.cpp
@ -642,7 +642,9 @@ EX void apply_other_model(shiftpoint H_orig, hyperpoint& ret, eModel md) {
|
|||||||
/* x wanes as z grows! */
|
/* x wanes as z grows! */
|
||||||
}
|
}
|
||||||
hyperpoint S = lie_log_correct(H_orig, H);
|
hyperpoint S = lie_log_correct(H_orig, H);
|
||||||
|
#if MAXMDIM >= 4
|
||||||
S[3] = 1;
|
S[3] = 1;
|
||||||
|
#endif
|
||||||
S = lp_apply(S);
|
S = lp_apply(S);
|
||||||
if(hyperbolic) {
|
if(hyperbolic) {
|
||||||
models::apply_orientation(ret[1], ret[0]);
|
models::apply_orientation(ret[1], ret[0]);
|
||||||
@ -652,12 +654,14 @@ EX void apply_other_model(shiftpoint H_orig, hyperpoint& ret, eModel md) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if MAXMDIM >= 4
|
||||||
case mdRelPerspective: {
|
case mdRelPerspective: {
|
||||||
auto S = rel_log(H_orig, true); S[3] = 1;
|
auto S = rel_log(H_orig, true); S[3] = 1;
|
||||||
S = lp_apply(S);
|
S = lp_apply(S);
|
||||||
apply_perspective(S, ret);
|
apply_perspective(S, ret);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
case mdPixel:
|
case mdPixel:
|
||||||
ret = H / current_display->radius;
|
ret = H / current_display->radius;
|
||||||
@ -912,6 +916,7 @@ EX void apply_other_model(shiftpoint H_orig, hyperpoint& ret, eModel md) {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if MAXMDIM >= 4
|
||||||
case mdRelOrthogonal: {
|
case mdRelOrthogonal: {
|
||||||
|
|
||||||
ret = rel_log(H_orig, true);
|
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);
|
if(!vrhr::rendering()) ret = lp_apply(ret);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
case mdHemisphere: {
|
case mdHemisphere: {
|
||||||
|
|
||||||
@ -2542,6 +2548,7 @@ EX void draw_model_elements() {
|
|||||||
dynamicval<ld> lw(vid.linewidth, vid.linewidth * vid.multiplier_ring);
|
dynamicval<ld> lw(vid.linewidth, vid.linewidth * vid.multiplier_ring);
|
||||||
switch(pmodel) {
|
switch(pmodel) {
|
||||||
|
|
||||||
|
#if MAXMDIM >= 4
|
||||||
case mdRelOrthogonal:
|
case mdRelOrthogonal:
|
||||||
case mdRelPerspective: {
|
case mdRelPerspective: {
|
||||||
constexpr ld cc = 3;
|
constexpr ld cc = 3;
|
||||||
@ -2565,6 +2572,7 @@ EX void draw_model_elements() {
|
|||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
case mdRotatedHyperboles: {
|
case mdRotatedHyperboles: {
|
||||||
queuestr(current_display->xcenter, current_display->ycenter + current_display->radius * pconf.alpha, 0, vid.fsize, "X", ringcolor, 1, 8);
|
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.
|
/** 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) {
|
EX hyperpoint rel_log(shiftpoint h, bool relativistic_length) {
|
||||||
if(sl2) {
|
if(sl2) {
|
||||||
optimize_shift(h);
|
optimize_shift(h);
|
||||||
@ -3341,6 +3350,7 @@ EX hyperpoint rel_log(shiftpoint h, bool relativistic_length) {
|
|||||||
}
|
}
|
||||||
throw hr_exception("rel_log in wrong geometry");
|
throw hr_exception("rel_log in wrong geometry");
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
/** Is Lie movement available? Depends on map geometry, not ambient geometry. */
|
/** Is Lie movement available? Depends on map geometry, not ambient geometry. */
|
||||||
EX bool lie_movement_available() {
|
EX bool lie_movement_available() {
|
||||||
@ -3351,7 +3361,9 @@ EX bool lie_movement_available() {
|
|||||||
|
|
||||||
EX hyperpoint lie_log(const shiftpoint h1) {
|
EX hyperpoint lie_log(const shiftpoint h1) {
|
||||||
hyperpoint h = unshift(h1);
|
hyperpoint h = unshift(h1);
|
||||||
if(nil) {
|
if(0) ;
|
||||||
|
#if MAXMDIM >= 4
|
||||||
|
else if(nil) {
|
||||||
h[3] = 0;
|
h[3] = 0;
|
||||||
h[2] -= h[0] * h[1] / 2;
|
h[2] -= h[0] * h[1] / 2;
|
||||||
}
|
}
|
||||||
@ -3380,6 +3392,10 @@ EX hyperpoint lie_log(const shiftpoint h1) {
|
|||||||
h[1] *= z / (exp(+z) - 1);
|
h[1] *= z / (exp(+z) - 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else if(sl2) {
|
||||||
|
return rel_log(h1, false);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
else if(euclid) {
|
else if(euclid) {
|
||||||
h[LDIM] = 0;
|
h[LDIM] = 0;
|
||||||
}
|
}
|
||||||
@ -3389,9 +3405,6 @@ EX hyperpoint lie_log(const shiftpoint h1) {
|
|||||||
for(int i=1; i<LDIM; i++)
|
for(int i=1; i<LDIM; i++)
|
||||||
h[i] *= h[0] / (exp(h[0])-1);
|
h[i] *= h[0] / (exp(h[0])-1);
|
||||||
}
|
}
|
||||||
else if(sl2) {
|
|
||||||
return rel_log(h1, false);
|
|
||||||
}
|
|
||||||
else {
|
else {
|
||||||
/* not implemented */
|
/* not implemented */
|
||||||
}
|
}
|
||||||
|
4
rug.cpp
4
rug.cpp
@ -870,7 +870,11 @@ bincode get_bincode(hyperpoint h) {
|
|||||||
case gcHyperbolic:
|
case gcHyperbolic:
|
||||||
return acd_bin(hypot_d(3, h));
|
return acd_bin(hypot_d(3, h));
|
||||||
case gcSphere: {
|
case gcSphere: {
|
||||||
|
#if MAXMDIM >= 4
|
||||||
return acd_bin(h[0]) + acd_bin(h[1]) * sY + acd_bin(h[2]) * sZ + acd_bin(h[3]) * sT;
|
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;
|
return 0;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user