1
0
mirror of https://github.com/zenorogue/hyperrogue.git synced 2024-06-16 18:29:59 +00:00

nisot::get_exp, just_direction parameter for inverse_exp, nsiot::geo_dist

This commit is contained in:
Zeno Rogue 2019-08-10 22:31:47 +02:00
parent cc0584f7d1
commit 3d119f39de

View File

@ -78,7 +78,7 @@ EX namespace solv {
return 0.5 - atan((0.5-x) / y) / M_PI; return 0.5 - atan((0.5-x) / y) / M_PI;
} }
hyperpoint get_inverse_exp(hyperpoint h, bool lazy) { hyperpoint get_inverse_exp(hyperpoint h, bool lazy, bool just_direction) {
load_table(); load_table();
ld ix = h[0] >= 0. ? x_to_ix(h[0]) : x_to_ix(-h[0]); ld ix = h[0] >= 0. ? x_to_ix(h[0]) : x_to_ix(-h[0]);
@ -120,11 +120,13 @@ EX namespace solv {
if(h[0] < 0.) res[0] = -res[0]; if(h[0] < 0.) res[0] = -res[0];
if(h[1] < 0.) res[1] = -res[1]; if(h[1] < 0.) res[1] = -res[1];
return res; if(!just_direction) {
ld r = hypot_d(3, res);
if(r == 0.) return res;
return res * atanh(r) / r;
}
/* ld r = sqrt(res[0] * res[0] + res[1] * res[1] + res[2] * res[2]); return res;
if(r == 0.) return res;
return res * atanh(r) / r; */
} }
struct hrmap_sol : hrmap { struct hrmap_sol : hrmap {
@ -556,11 +558,16 @@ EX namespace nisot {
enum iePrecision { iLazy, iTable }; enum iePrecision { iLazy, iTable };
#endif #endif
EX hyperpoint inverse_exp(const hyperpoint h, iePrecision p) { EX hyperpoint inverse_exp(const hyperpoint h, iePrecision p, bool just_direction IS(true)) {
if(sol) return solv::get_inverse_exp(h, p == iLazy); if(sol) return solv::get_inverse_exp(h, p == iLazy, just_direction);
if(nil) return nilv::get_inverse_exp(h, p == iLazy ? 5 : 20); if(nil) return nilv::get_inverse_exp(h, p == iLazy ? 5 : 20);
return point3(h[0], h[1], h[2]); return point3(h[0], h[1], h[2]);
} }
EX ld geo_dist(const hyperpoint h1, const hyperpoint h2, iePrecision p) {
if(!nonisotropic) return hdist(h1, h2);
return hypot_d(3, inverse_exp(inverse(translate(h1)) * h2, p, false));
}
EX void geodesic_step(hyperpoint& at, hyperpoint& velocity) { EX void geodesic_step(hyperpoint& at, hyperpoint& velocity) {
auto acc = christoffel(at, velocity, velocity); auto acc = christoffel(at, velocity, velocity);
@ -583,6 +590,12 @@ EX namespace nisot {
return at; return at;
} }
EX hyperpoint get_exp(hyperpoint v, int steps) {
if(sol) return direct_exp(v, steps);
if(nil) return nilv::formula_exp(v);
return v;
}
EX transmatrix parallel_transport_bare(transmatrix Pos, transmatrix T) { EX transmatrix parallel_transport_bare(transmatrix Pos, transmatrix T) {
hyperpoint h = tC0(T); hyperpoint h = tC0(T);