1
0
mirror of https://github.com/zenorogue/hyperrogue.git synced 2025-11-16 13:48:04 +00:00

preliminary S2xE

This commit is contained in:
Zeno Rogue
2019-08-18 16:58:44 +02:00
parent 081bb55202
commit e636d3f40c
4 changed files with 45 additions and 11 deletions

View File

@@ -171,7 +171,7 @@ ld inverse_tanh(ld x) { return log((1+x)/(1-x)) / 2; } */
EX ld squar(ld x) { return x*x; }
EX int sig(int z) { return prod ? (z<2?1:-1) : (sphere || sol || z<GDIM)?1:-1; }
EX int sig(int z) { return prod ? PIU(sig(z)) : (sphere || sol || z<GDIM)?1:-1; }
EX int curvature() {
switch(cgclass) {
@@ -230,6 +230,15 @@ EX ld asin_auto_clamp(ld x) {
}
}
EX ld acos_auto_clamp(ld x) {
switch(cgclass) {
case gcHyperbolic: return x < 1 ? 0 : acosh(x);
case gcSphere: return x > 1 ? 0 : x < -1 ? M_PI : acos(x);
case gcProduct: return PIU(acos_auto_clamp(x));
default: return x;
}
}
EX ld cos_auto(ld x) {
switch(cgclass) {
case gcEuclid: return 1;
@@ -339,7 +348,7 @@ EX ld hypot_d(int d, const hyperpoint& h) {
EX ld zlevel(const hyperpoint &h) {
if(translatable) return h[LDIM];
else if(sphere) return sqrt(intval(h, Hypc));
else if(prod) return log(sqrt(-intval(h, Hypc)));
else if(prod) return log(sqrt(abs(intval(h, Hypc)))); /* abs works with both underlying spherical and hyperbolic */
else return (h[LDIM] < 0 ? -1 : 1) * sqrt(-intval(h, Hypc));
}