fixed a bug with hdist returning nan due to precision errors

This commit is contained in:
Zeno Rogue 2019-03-03 00:45:56 +01:00
parent 8d2b6a0093
commit 7e2f6629fd
1 changed files with 2 additions and 0 deletions

View File

@ -588,8 +588,10 @@ double hdist(const hyperpoint& h1, const hyperpoint& h2) {
ld iv = intval(h1, h2);
switch(cgclass) {
case gcEuclid:
if(iv < 0) return 0;
return sqrt(iv);
case gcHyperbolic:
if(iv < 0) return 0;
return 2 * asinh(sqrt(iv) / 2);
case gcSphere:
return 2 * asin_auto_clamp(sqrt(iv) / 2);