mirror of
https://github.com/zenorogue/hyperrogue.git
synced 2025-10-24 18:37:39 +00:00
nisot:: nicer precision setting
This commit is contained in:
@@ -552,7 +552,7 @@ EX namespace sn {
|
||||
}
|
||||
}
|
||||
|
||||
EX hyperpoint get_inverse_exp_symsol(hyperpoint h, bool lazy, bool just_direction) {
|
||||
EX hyperpoint get_inverse_exp_symsol(hyperpoint h, flagtype flags) {
|
||||
auto& s = get_tabled();
|
||||
s.load();
|
||||
|
||||
@@ -562,18 +562,17 @@ EX namespace sn {
|
||||
|
||||
if(h[2] < 0.) { iz = -iz; swap(ix, iy); }
|
||||
|
||||
hyperpoint res = s.get(ix, iy, iz, lazy);
|
||||
hyperpoint res = s.get(ix, iy, iz, flags & pfNO_INTERPOLATION);
|
||||
|
||||
if(h[2] < 0.) { swap(res[0], res[1]); res[2] = -res[2]; }
|
||||
if(h[0] < 0.) res[0] = -res[0];
|
||||
if(h[1] < 0.) res[1] = -res[1];
|
||||
|
||||
if(!just_direction) return table_to_azeq(res);
|
||||
|
||||
return res;
|
||||
if(flags & pfNO_DISTANCE) return res;
|
||||
return table_to_azeq(res);
|
||||
}
|
||||
|
||||
EX hyperpoint get_inverse_exp_nsym(hyperpoint h, bool lazy, bool just_direction) {
|
||||
EX hyperpoint get_inverse_exp_nsym(hyperpoint h, flagtype flags) {
|
||||
auto& s = get_tabled();
|
||||
s.load();
|
||||
|
||||
@@ -581,14 +580,13 @@ EX namespace sn {
|
||||
ld iy = h[1] >= 0. ? sn::x_to_ix(h[1]) : sn::x_to_ix(-h[1]);
|
||||
ld iz = sn::z_to_iz(h[2]);
|
||||
|
||||
hyperpoint res = s.get(ix, iy, iz, lazy);
|
||||
hyperpoint res = s.get(ix, iy, iz, flags & pfNO_INTERPOLATION);
|
||||
|
||||
if(h[0] < 0.) res[0] = -res[0];
|
||||
if(h[1] < 0.) res[1] = -res[1];
|
||||
|
||||
if(!just_direction) return table_to_azeq(res);
|
||||
|
||||
return res;
|
||||
if(flags & pfNO_DISTANCE) return res;
|
||||
return table_to_azeq(res);
|
||||
}
|
||||
|
||||
EX string shader_symsol = sn::common +
|
||||
@@ -745,7 +743,7 @@ EX namespace nilv {
|
||||
);
|
||||
}
|
||||
|
||||
EX hyperpoint get_inverse_exp(hyperpoint h, int iterations) {
|
||||
EX hyperpoint get_inverse_exp(hyperpoint h, flagtype prec IS(pNORMAL)) {
|
||||
ld wmin, wmax;
|
||||
|
||||
ld side = h[2] - h[0] * h[1] / 2;
|
||||
@@ -769,11 +767,13 @@ EX namespace nilv {
|
||||
|
||||
ld s = sin(2 * alpha_total);
|
||||
|
||||
int max_iter = (prec & pfLOW_BS_ITER) ? 5 : 20;
|
||||
|
||||
for(int it=0;; it++) {
|
||||
ld w = (wmin + wmax) / 2;
|
||||
ld z = b * b * (s + (sin(w) - w)/(cos(w) - 1)) + w;
|
||||
|
||||
if(it == iterations) {
|
||||
if(it == max_iter) {
|
||||
ld alpha = alpha_total - w/2;
|
||||
ld c = b / sin(w/2);
|
||||
return point3(c * w * cos(alpha), c * w * sin(alpha), w);
|
||||
@@ -967,7 +967,7 @@ EX namespace nilv {
|
||||
|
||||
EX hyperpoint on_geodesic(hyperpoint s0, hyperpoint s1, ld x) {
|
||||
hyperpoint local = inverse(nisot::translate(s0)) * s1;
|
||||
hyperpoint h = get_inverse_exp(local, 100);
|
||||
hyperpoint h = get_inverse_exp(local);
|
||||
return nisot::translate(s0) * formula_exp(h * x);
|
||||
}
|
||||
|
||||
@@ -1822,7 +1822,7 @@ EX namespace rots {
|
||||
hybrid::in_underlying_geometry([&] {
|
||||
hyperpoint h = tC0(T);
|
||||
Spin = inverse(gpushxto0(h) * T);
|
||||
d = hr::inverse_exp(h, iTable);
|
||||
d = hr::inverse_exp(h);
|
||||
alpha = atan2(Spin[0][1], Spin[0][0]);
|
||||
distance = hdist0(h);
|
||||
beta = atan2(h[1], h[0]);
|
||||
@@ -1986,11 +1986,14 @@ EX namespace nisot {
|
||||
vel += (acc1+2*acc2+2*acc3+acc4)/6;
|
||||
}
|
||||
|
||||
EX hyperpoint numerical_exp(hyperpoint v, int steps) {
|
||||
EX int rk_steps = 20;
|
||||
EX int pt_steps = 100;
|
||||
|
||||
EX hyperpoint numerical_exp(hyperpoint v) {
|
||||
hyperpoint at = point31(0, 0, 0);
|
||||
v /= steps;
|
||||
v /= rk_steps;
|
||||
v[3] = 0;
|
||||
for(int i=0; i<steps; i++) geodesic_step(at, v);
|
||||
for(int i=0; i<rk_steps; i++) geodesic_step(at, v);
|
||||
return at;
|
||||
}
|
||||
|
||||
@@ -2045,12 +2048,12 @@ EX namespace nisot {
|
||||
return parallel_transport_bare(P, direction);
|
||||
}
|
||||
|
||||
EX transmatrix spin_towards(const transmatrix Position, const hyperpoint goal) {
|
||||
EX transmatrix spin_towards(const transmatrix Position, const hyperpoint goal, flagtype prec IS(pNORMAL)) {
|
||||
|
||||
hyperpoint at = tC0(Position);
|
||||
transmatrix push_back = inverse(translate(at));
|
||||
hyperpoint back_goal = push_back * goal;
|
||||
back_goal = inverse_exp(back_goal, iTable);
|
||||
back_goal = inverse_exp(back_goal, prec);
|
||||
|
||||
transmatrix back_Position = push_back * Position;
|
||||
|
||||
@@ -2133,6 +2136,11 @@ EX namespace nisot {
|
||||
shift_arg_formula(nilv::nilwidth);
|
||||
return 0;
|
||||
}
|
||||
else if(argis("-rk-steps")) {
|
||||
PHASEFROM(2);
|
||||
shift(); rk_steps = argi();
|
||||
return 0;
|
||||
}
|
||||
else if(argis("-nilv")) {
|
||||
PHASEFROM(2);
|
||||
if(nil) stop_game();
|
||||
|
||||
Reference in New Issue
Block a user