mirror of
https://github.com/zenorogue/hyperrogue.git
synced 2025-03-28 22:37:03 +00:00
compute_edgelength accepts inf-faces
This commit is contained in:
parent
506a8b8f1b
commit
32ff898cd1
@ -160,13 +160,20 @@ EX ld compute_edgelength(vector<pair<ld, ld>> facemul, ld halftotal IS(M_PI)) {
|
|||||||
edgelength = (elmin + elmax) / 2;
|
edgelength = (elmin + elmax) / 2;
|
||||||
ld alpha_total = 0;
|
ld alpha_total = 0;
|
||||||
for(auto fm: facemul) {
|
for(auto fm: facemul) {
|
||||||
ld gamma = M_PI / fm.first;
|
if(isinf(fm.first)) {
|
||||||
auto c = asin_auto(sin_auto(edgelength/2) / sin(gamma));
|
ld u = sqrt(cosh(edgelength) * 2 - 2);
|
||||||
hyperpoint h = xpush(c) * spin(M_PI - 2*gamma) * xpush0(c);
|
ld a = atan2(1, u/2);
|
||||||
ld a = atan2(h);
|
alpha_total += a * fm.second;
|
||||||
cyclefix(a, 0);
|
}
|
||||||
if(a < 0) a = -a;
|
else {
|
||||||
alpha_total += a * fm.second;
|
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;
|
if(isnan(alpha_total)) elmax = edgelength;
|
||||||
else if(sphere ^ (alpha_total > halftotal)) elmin = edgelength;
|
else if(sphere ^ (alpha_total > halftotal)) elmin = edgelength;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user