From: ageay Date: Thu, 5 Nov 2009 10:06:32 +0000 (+0000) Subject: Protection of acos against values out of [-1.,1.] X-Git-Tag: V5_1_main_FINAL~284 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=8d546c74b7d4b4af0e42340ed191fd2763893b89;p=tools%2Fmedcoupling.git Protection of acos against values out of [-1.,1.] --- diff --git a/src/INTERP_KERNEL/TransformedTriangleMath.cxx b/src/INTERP_KERNEL/TransformedTriangleMath.cxx index 4dd23859c..047c59bf9 100644 --- a/src/INTERP_KERNEL/TransformedTriangleMath.cxx +++ b/src/INTERP_KERNEL/TransformedTriangleMath.cxx @@ -354,7 +354,10 @@ namespace INTERP_KERNEL //? is this more stable? -> no subtraction // return asin( dotProd / ( lenNormal * lenEdgeVec ) ) + 3.141592625358979 / 2.0; - return atan(1.0)*4.0 - acos( dotProd / ( lenNormal * lenEdgeVec ) ); + double tmp=dotProd / ( lenNormal * lenEdgeVec ); + tmp=std::max(tmp,-1.); + tmp=std::min(tmp,1.); + return atan(1.0)*4.0 - acos(tmp); }