From 23695cca798bcdea349623ac743e736514fb9ff4 Mon Sep 17 00:00:00 2001 From: "Dmitry Yu. Naumov" <github@naumov.de> Date: Sun, 19 Jul 2015 20:17:23 +0000 Subject: [PATCH] [MaL] Use std::fabs. Rename tol to eps. --- MathLib/TemplatePoint.h | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/MathLib/TemplatePoint.h b/MathLib/TemplatePoint.h index 5fda916ef8f..81584c58aab 100644 --- a/MathLib/TemplatePoint.h +++ b/MathLib/TemplatePoint.h @@ -134,30 +134,30 @@ bool operator< (TemplatePoint<T,DIM> const& a, TemplatePoint<T,DIM> const& b) * lexicographical comparison of points taking an epsilon into account * @param p0 first input Point3d * @param p1 second input Point3d - * @param tol tolerance (if in the comparison operation the property fabs(p0[k] - p1[k]) < tol + * @param eps tolerance (if in the comparison operation the property abs(p0[k] - p1[k]) < eps * holds for the k-th coordinate the points are assumed the be equal in this coordinate) * @return true, if p0 is lexicographically smaller than p1 */ template <typename T, std::size_t DIM> bool lessEq(TemplatePoint<T, DIM> const& a, TemplatePoint<T, DIM> const& b, - double tol = std::numeric_limits<double>::epsilon()) + double eps = std::numeric_limits<double>::epsilon()) { // test a relative and an absolute criterion - if (fabs(a[0]-b[0]) > tol * std::min(fabs(b[0]), fabs(a[0])) && fabs(a[0]-b[0]) > tol) { + if ((std::fabs(a[0]-b[0]) > eps * std::min(std::fabs(b[0]), std::fabs(a[0])) && std::fabs(a[0]-b[0]) > eps) { if (a[0] <= b[0]) return true; else return false; } else { // assume a[0] == b[0] - if (fabs (a[1]-b[1]) > tol * fabs(a[1]) && fabs(a[1]-b[1]) > tol) { + if (std::fabs (a[1]-b[1]) > eps * std::fabs(a[1]) && std::fabs(a[1]-b[1]) > eps) { if (a[1] <= b[1]) return true; else return false; } else { // assume a[1] == b[1] and a[0] == b[0] - if (fabs (a[2]-b[2]) > tol * fabs(a[2]) && fabs(a[2]-b[2]) > tol) { + if (std::fabs (a[2]-b[2]) > eps * std::fabs(a[2]) && std::fabs(a[2]-b[2]) > eps) { if (a[2] <= b[2]) return true; else -- GitLab