From: BRUNO LATHUILIERE Date: Tue, 27 Feb 2024 13:37:49 +0000 (+0100) Subject: cosmetics floating point fix X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=3dd421db0e02128400a98c60c383825c212e406a;p=tools%2Fmedcoupling.git cosmetics floating point fix --- 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); } /**