From 3dd421db0e02128400a98c60c383825c212e406a Mon Sep 17 00:00:00 2001 From: BRUNO LATHUILIERE Date: Tue, 27 Feb 2024 14:37:49 +0100 Subject: [PATCH] cosmetics floating point fix --- src/INTERP_KERNEL/TransformedTriangle.hxx | 2 +- src/INTERP_KERNEL/TransformedTriangleMath.cxx | 10 ++++------ 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/src/INTERP_KERNEL/TransformedTriangle.hxx b/src/INTERP_KERNEL/TransformedTriangle.hxx index b2ce44315..14d396597 100644 --- a/src/INTERP_KERNEL/TransformedTriangle.hxx +++ b/src/INTERP_KERNEL/TransformedTriangle.hxx @@ -512,7 +512,7 @@ namespace INTERP_KERNEL if (std::fabs(t1+t2) < THRESHOLD_F*MULT_PREC_F) return false; - return (t1*t2 <= 0.0) && !epsilonEqual(t1,t2, (double)MULT_PREC_F); + return (t1*t2 <= 0.0) && !epsilonEqual(t1,t2, MULT_PREC_F); } inline bool TransformedTriangle::testFacetSurroundsSegment(const TriSegment seg, const TetraFacet facet) const diff --git a/src/INTERP_KERNEL/TransformedTriangleMath.cxx b/src/INTERP_KERNEL/TransformedTriangleMath.cxx index 30ecbc621..7b3eba4e8 100644 --- a/src/INTERP_KERNEL/TransformedTriangleMath.cxx +++ b/src/INTERP_KERNEL/TransformedTriangleMath.cxx @@ -331,7 +331,7 @@ namespace INTERP_KERNEL { // this value will not be used - we set it to whatever LOG(6, "Triple product not calculated for corner " << corner ); - _tripleProducts[corner] = -3.14159265; + _tripleProducts[corner] = std::nan("triplep"); _validTP[corner] = false; } anglesForRows.clear(); @@ -390,11 +390,9 @@ namespace INTERP_KERNEL //? is this more stable? -> no subtraction // return asin( dotProd / ( lenNormal * lenEdgeVec ) ) + 3.141592625358979 / 2.0; - double tmp=dotProd / ( lenNormal * lenEdgeVec ); - tmp=std::max(tmp,-1.); - tmp=std::min(tmp,1.); - return atan(1.0)*4.0 - acos(tmp); - + const double tmp=dotProd / ( lenNormal * lenEdgeVec ); + const double safe_tmp=std::max(std::min(tmp,1.),-1.); + return M_PI - std::acos(safe_tmp); } /** -- 2.39.2