1
0
mirror of https://github.com/zenorogue/hyperrogue.git synced 2024-12-29 19:40:35 +00:00

compute_edgelength accepts inf-faces

This commit is contained in:
Zeno Rogue 2022-04-21 22:09:23 +02:00
parent 506a8b8f1b
commit 32ff898cd1

View File

@ -160,6 +160,12 @@ EX ld compute_edgelength(vector<pair<ld, ld>> facemul, ld halftotal IS(M_PI)) {
edgelength = (elmin + elmax) / 2;
ld alpha_total = 0;
for(auto fm: facemul) {
if(isinf(fm.first)) {
ld u = sqrt(cosh(edgelength) * 2 - 2);
ld a = atan2(1, u/2);
alpha_total += a * fm.second;
}
else {
ld gamma = M_PI / fm.first;
auto c = asin_auto(sin_auto(edgelength/2) / sin(gamma));
hyperpoint h = xpush(c) * spin(M_PI - 2*gamma) * xpush0(c);
@ -168,6 +174,7 @@ EX ld compute_edgelength(vector<pair<ld, ld>> facemul, ld halftotal IS(M_PI)) {
if(a < 0) a = -a;
alpha_total += a * fm.second;
}
}
if(isnan(alpha_total)) elmax = edgelength;
else if(sphere ^ (alpha_total > halftotal)) elmin = edgelength;
else elmax = edgelength;