From da1251ada2a70f5413eec60829dafe4521016212 Mon Sep 17 00:00:00 2001 From: Matthias Koefferlein Date: Wed, 16 Aug 2023 22:19:33 +0200 Subject: [PATCH] Fixed a numerical issue with vprod_sign etc. - was using a too coarse precision value to decide about the sign --- src/db/db/dbTypes.h | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/src/db/db/dbTypes.h b/src/db/db/dbTypes.h index f7fecc781..82498c67e 100644 --- a/src/db/db/dbTypes.h +++ b/src/db/db/dbTypes.h @@ -32,6 +32,16 @@ namespace db { +/** + * @brief A generic constant describing the "fuzzyness" of a double comparison of a value around 1 + */ +const double epsilon = 1e-10; + +/** + * @brief A generic constant describing the "fuzzyness" of a float comparison of a value around 1 + */ +const double fepsilon = 1e-6; + /** * @brief The standard integer coordinate type */ @@ -424,7 +434,7 @@ struct coord_traits { double dx1 = ax - cx, dy1 = ay - cy; double dx2 = bx - cx, dy2 = by - cy; - double pa = (sqrt (dx1 * dx1 + dy1 * dy1) + sqrt (dx2 * dx2 + dy2 * dy2)) * prec (); + double pa = (sqrt (dx1 * dx1 + dy1 * dy1) + sqrt (dx2 * dx2 + dy2 * dy2)) * db::epsilon; area_type p1 = dx1 * dx2; area_type p2 = -dy1 * dy2; if (p1 <= p2 - pa) { @@ -440,7 +450,7 @@ struct coord_traits { double dx1 = ax - cx, dy1 = ay - cy; double dx2 = bx - cx, dy2 = by - cy; - double pa = (sqrt (dx1 * dx1 + dy1 * dy1) + sqrt (dx2 * dx2 + dy2 * dy2)) * prec (); + double pa = (sqrt (dx1 * dx1 + dy1 * dy1) + sqrt (dx2 * dx2 + dy2 * dy2)) * db::epsilon; area_type p1 = dx1 * dx2; area_type p2 = -dy1 * dy2; if (p1 <= p2 - pa) { @@ -463,7 +473,7 @@ struct coord_traits { double dx1 = ax - cx, dy1 = ay - cy; double dx2 = bx - cx, dy2 = by - cy; - double pa = (sqrt (dx1 * dx1 + dy1 * dy1) + sqrt (dx2 * dx2 + dy2 * dy2)) * prec (); + double pa = (sqrt (dx1 * dx1 + dy1 * dy1) + sqrt (dx2 * dx2 + dy2 * dy2)) * db::epsilon; area_type p1 = dx1 * dy2; area_type p2 = dy1 * dx2; if (p1 <= p2 - pa) { @@ -479,7 +489,7 @@ struct coord_traits { double dx1 = ax - cx, dy1 = ay - cy; double dx2 = bx - cx, dy2 = by - cy; - double pa = (sqrt (dx1 * dx1 + dy1 * dy1) + sqrt (dx2 * dx2 + dy2 * dy2)) * prec (); + double pa = (sqrt (dx1 * dx1 + dy1 * dy1) + sqrt (dx2 * dx2 + dy2 * dy2)) * db::epsilon; area_type p1 = dx1 * dy2; area_type p2 = dy1 * dx2; if (p1 <= p2 - pa) { @@ -537,16 +547,6 @@ struct cast_op } }; -/** - * @brief A generic constant describing the "fuzzyness" of a double comparison of a value around 1 - */ -const double epsilon = 1e-10; - -/** - * @brief A generic constant describing the "fuzzyness" of a float comparison of a value around 1 - */ -const double fepsilon = 1e-6; - /** * @brief A functor wrapping the epsilon constant in a templatized form */