1
0
mirror of https://github.com/zenorogue/hyperrogue.git synced 2024-11-10 15:59:53 +00:00

sn:: solv-table generator: more precise ix_to_x

This commit is contained in:
Zeno Rogue 2020-01-15 18:10:12 +01:00
parent 549aa5bdb1
commit e964ede86d

View File

@ -195,13 +195,15 @@ void alloc_table(sn::tabled_inverses& tab, int X, int Y, int Z) {
} }
ld ix_to_x(ld ix) { ld ix_to_x(ld ix) {
ld minx = 0, maxx = 1; ld minx = 0;
for(int it=0; it<100; it++) { while(x_to_ix(minx) <= ix) minx++;
ld maxx = minx; minx--;
for(int it=0; it<20; it++) {
ld x = (minx + maxx) / 2; ld x = (minx + maxx) / 2;
if(x_to_ix(atanh(x)) < ix) minx = x; if(x_to_ix(x) < ix) minx = x;
else maxx = x; else maxx = x;
} }
return atanh(minx); return minx;
} }
ld iz_to_z(ld z) { ld iz_to_z(ld z) {