const std::size_t m = polygon.size();
for(int j = 0 ; j < 3 ; ++j)
- {
- barycenter[j] = 0.0;
- }
+ barycenter[j] = 0.0;
+
+ for(std::size_t i = 0 ; i < m ; ++i)
+ {
+ const double* pt = polygon[i];
+ for(int j = 0 ; j < 3 ; ++j)
+ barycenter[j] += pt[j];
+ }
if(m != 0)
{
- for(std::size_t i = 0 ; i < m ; ++i)
- {
- const double* pt = polygon[i];
- for(int j = 0 ; j < 3 ; ++j)
- {
- barycenter[j] += pt[j] / double(m);
- }
- }
+ for(int j = 0 ; j < 3 ; ++j)
+ barycenter[j] = barycenter[j] / double(m);
}
LOG(3,"Barycenter is " << vToStr(barycenter));
}
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
{
// 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();
//? 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);
}
/**