1
0
mirror of https://github.com/zenorogue/hyperrogue.git synced 2024-12-26 01:50:36 +00:00

rogueviz::sag:: angular distances

This commit is contained in:
Zeno Rogue 2022-10-23 15:48:20 +02:00
parent d39623fdd5
commit 15d97a8cd1

View File

@ -22,6 +22,8 @@ namespace sag {
int sagpar = 0; int sagpar = 0;
bool angular = false;
int best_cost = 1000000000; int best_cost = 1000000000;
enum eSagmode { sagOff, sagHC, sagSA }; enum eSagmode { sagOff, sagHC, sagSA };
@ -518,24 +520,14 @@ namespace sag {
} }
ld pdist(hyperpoint hi, hyperpoint hj) { ld pdist(hyperpoint hi, hyperpoint hj) {
if(sol) { if(sol) return min(geo_dist(hi, hj), geo_dist(hj, hi));
hyperpoint h = rgpushxto0(hi) * hj; if(prod && angular) {
h[0] = abs(h[0]); auto di = product_decompose(hi);
h[1] = abs(h[1]); auto dj = product_decompose(hj);
ld x = hdist(di.second, dj.second);
ld d1 = approx_01(h); ld z = di.first - dj.first;
ld d2 = approx_01(hyperpoint(h[1], h[0], -h[2], 1)); return log((x*x+z*z) * (x > 0 ? sinh(x) / x : 0));
h = rgpushxto0(hj) * hi;
h[0] = abs(h[0]);
h[1] = abs(h[1]);
ld d3 = approx_01(h);
ld d4 = approx_01(hyperpoint(h[1], h[0], -h[2], 1));
return min(min(d1, d2), min(d3, d4));
} }
return geo_dist(hi, hj); return geo_dist(hi, hj);
}; };
@ -1039,6 +1031,9 @@ int readArgs() {
else if(argis("-sagstats")) { else if(argis("-sagstats")) {
output_stats(); output_stats();
} }
else if(argis("-sag-angular")) {
shift(); angular = argi();
}
else if(argis("-sagstats-logid")) { else if(argis("-sagstats-logid")) {
shift(); logid = argi(); shift(); logid = argi();
} }