compute_edgelength accepts inf-faces

This commit is contained in:
Zeno Rogue 2022-04-21 22:09:23 +02:00
parent 506a8b8f1b
commit 32ff898cd1
1 changed files with 14 additions and 7 deletions

View File

@ -160,13 +160,20 @@ 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) {
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);
ld a = atan2(h);
cyclefix(a, 0);
if(a < 0) a = -a;
alpha_total += a * fm.second;
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);
ld a = atan2(h);
cyclefix(a, 0);
if(a < 0) a = -a;
alpha_total += a * fm.second;
}
}
if(isnan(alpha_total)) elmax = edgelength;
else if(sphere ^ (alpha_total > halftotal)) elmin = edgelength;