[geos-commits] [SCM] GEOS branch main updated. b8222e43d37e560850d523ac7321705a0b84262d

git at osgeo.org git at osgeo.org
Mon Feb 3 12:44:22 PST 2025


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "GEOS".

The branch, main has been updated
       via  b8222e43d37e560850d523ac7321705a0b84262d (commit)
       via  50f3c5f56b7c463968d1e35870673b2970bc4afc (commit)
       via  c525cb41e12a6490085f7493ecd87dd59099a909 (commit)
       via  8e4e03ee3b871181b801a38d8aedd36b5d8899f0 (commit)
      from  c679bff3e99208336c11aee3f9a6b16d9c4f85c0 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit b8222e43d37e560850d523ac7321705a0b84262d
Merge: c679bff3e 50f3c5f56
Author: Paul Ramsey <pramsey at cleverelephant.ca>
Date:   Mon Feb 3 12:43:50 2025 -0800

    Merge branch 'tinko92-orientation-tighter-error-bound'


commit 50f3c5f56b7c463968d1e35870673b2970bc4afc
Author: Paul Ramsey <pramsey at cleverelephant.ca>
Date:   Mon Feb 3 12:41:36 2025 -0800

    Update comment on orientationIndexFilter()

diff --git a/include/geos/algorithm/CGAlgorithmsDD.h b/include/geos/algorithm/CGAlgorithmsDD.h
index 44e64c0cc..7641e5f46 100644
--- a/include/geos/algorithm/CGAlgorithmsDD.h
+++ b/include/geos/algorithm/CGAlgorithmsDD.h
@@ -77,15 +77,22 @@ public:
      * A filter for computing the orientation index of three coordinates.
      *
      * If the orientation can be computed safely using standard DP arithmetic,
-     * this routine returns the orientation index. Otherwise, a value `i > 1` is
-     * returned. In this case the orientation index must be computed using some
-     * other more robust method.
+     * this routine returns the orientation index.
      *
      * The filter is fast to compute, so can be used to avoid the use of slower
      * robust methods except when they are really needed, thus providing better
      * average performance.
      *
-     * Uses an approach due to Jonathan Shewchuk, which is in the public domain.
+     * Jonathan Shewchuk
+     * Robust Adaptive Floating-Point Geometric Predicates
+     * Proceedings of the Twelfth Annual Symposium on Computational Geometry, ACM,
+     * May 1996
+     *
+     * Ozaki, K., Bünger, F., Ogita, T. et al.
+     * Simple floating-point filters for the two-dimensional orientation problem.
+     * Bit Numer Math 56, 729–749 (2016).
+     * https://doi.org/10.1007/s10543-015-0574-9
+     *
      */
     static inline int orientationIndexFilter(
         double pax, double pay,
@@ -95,7 +102,7 @@ public:
         double const detleft = (pax - pcx) * (pby - pcy);
         double const detright = (pay - pcy) * (pbx - pcx);
         double const det = detleft - detright;
-        // Coefficient due to https://doi.org/10.1007/s10543-015-0574-9
+        // Coefficient as per Ozaki et al
         double const error = std::abs(detleft + detright)
                              * 3.3306690621773724e-16;
         if (std::abs(det) >= error)

commit c525cb41e12a6490085f7493ecd87dd59099a909
Merge: c679bff3e 8e4e03ee3
Author: Paul Ramsey <pramsey at cleverelephant.ca>
Date:   Mon Feb 3 12:36:50 2025 -0800

    Merge branch 'orientation-tighter-error-bound' of github.com:tinko92/geos into tinko92-orientation-tighter-error-bound


commit 8e4e03ee3b871181b801a38d8aedd36b5d8899f0
Author: tinko92 <mail at tinkobartels.de>
Date:   Sun Oct 27 09:16:25 2024 +0800

    Use Ozaki et al.'s error bound and single-branch evaluation in orientation index filter.

diff --git a/include/geos/algorithm/CGAlgorithmsDD.h b/include/geos/algorithm/CGAlgorithmsDD.h
index ef251c3ee..a3ca957ce 100644
--- a/include/geos/algorithm/CGAlgorithmsDD.h
+++ b/include/geos/algorithm/CGAlgorithmsDD.h
@@ -20,6 +20,7 @@
 
 #include <geos/export.h>
 #include <geos/math/DD.h>
+#include <cmath>
 
 // Forward declarations
 namespace geos {
@@ -92,41 +93,14 @@ public:
         double pbx, double pby,
         double pcx, double pcy)
     {
-        /**
-         * A value which is safely greater than the relative round-off
-         * error in double-precision numbers
-         */
-        double constexpr DP_SAFE_EPSILON =  1e-15;
-
-        double detsum;
         double const detleft = (pax - pcx) * (pby - pcy);
         double const detright = (pay - pcy) * (pbx - pcx);
         double const det = detleft - detright;
-
-        if(detleft > 0.0) {
-            if(detright <= 0.0) {
-                return orientation(det);
-            }
-            else {
-                detsum = detleft + detright;
-            }
-        }
-        else if(detleft < 0.0) {
-            if(detright >= 0.0) {
-                return orientation(det);
-            }
-            else {
-                detsum = -detleft - detright;
-            }
-        }
-        else {
-            return orientation(det);
-        }
-
-        double const errbound = DP_SAFE_EPSILON * detsum;
-        if((det >= errbound) || (-det >= errbound)) {
-            return orientation(det);
-        }
+        // Coefficient due to https://doi.org/10.1007/s10543-015-0574-9
+        double const error = std::abs(detleft + detright)
+                             * 3.3306690621773724e-16;
+        if (std::abs(det) >= error)
+            return (det > 0) - (det < 0);
         return CGAlgorithmsDD::FAILURE;
     };
 
@@ -188,6 +162,3 @@ protected:
 
 } // namespace geos::algorithm
 } // namespace geos
-
-
-

-----------------------------------------------------------------------

Summary of changes:
 include/geos/algorithm/CGAlgorithmsDD.h | 56 ++++++++++-----------------------
 1 file changed, 17 insertions(+), 39 deletions(-)


hooks/post-receive
-- 
GEOS


More information about the geos-commits mailing list