diff --git a/modules/core/src/main/java/org/locationtech/jts/algorithm/CGAlgorithmsDD.java b/modules/core/src/main/java/org/locationtech/jts/algorithm/CGAlgorithmsDD.java index 44c92999c..2e4f61091 100644 --- a/modules/core/src/main/java/org/locationtech/jts/algorithm/CGAlgorithmsDD.java +++ b/modules/core/src/main/java/org/locationtech/jts/algorithm/CGAlgorithmsDD.java @@ -108,12 +108,6 @@ public static int signOfDet2x2(double dx1, double dy1, double dx2, double dy2) return det.signum(); } - /** - * A value which is safely greater than the - * relative round-off error in double-precision numbers - */ - private static final double DP_SAFE_EPSILON = 1e-15; - /** * A filter for computing the orientation index of three coordinates. *
@@ -126,7 +120,8 @@ public static int signOfDet2x2(double dx1, double dy1, double dx2, double dy2) * 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. + * Uses an approach due to Ozaki et al., which is published at + * doi:10.1007/s10543-015-0574-9. * * @param pax A coordinate * @param pay A coordinate @@ -140,34 +135,12 @@ public static int signOfDet2x2(double dx1, double dy1, double dx2, double dy2) private static int orientationIndexFilter(double pax, double pay, double pbx, double pby, double pcx, double pcy) { - double detsum; - double detleft = (pax - pcx) * (pby - pcy); double detright = (pay - pcy) * (pbx - pcx); double det = detleft - detright; - if (detleft > 0.0) { - if (detright <= 0.0) { - return signum(det); - } - else { - detsum = detleft + detright; - } - } - else if (detleft < 0.0) { - if (detright >= 0.0) { - return signum(det); - } - else { - detsum = -detleft - detright; - } - } - else { - return signum(det); - } - - double errbound = DP_SAFE_EPSILON * detsum; - if ((det >= errbound) || (-det >= errbound)) { + double errbound = Math.abs(detleft + detright) * 3.3306690621773724e-16; + if (Math.abs(det) >= errbound) { return signum(det); }