]> SALOME platform Git repositories - tools/medcoupling.git/commitdiff
Salome HOME
Protection of acos against values out of [-1.,1.]
authorageay <ageay>
Thu, 5 Nov 2009 10:06:32 +0000 (10:06 +0000)
committerageay <ageay>
Thu, 5 Nov 2009 10:06:32 +0000 (10:06 +0000)
src/INTERP_KERNEL/TransformedTriangleMath.cxx

index 4dd23859cb58022737228ee627aa1c0bd325e28f..047c59bf95608364a1d72110593957e8dd3c36f4 100644 (file)
@@ -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);
 
   }