Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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.
* <p>
Expand All @@ -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.
* <p>
* 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
* <a href="https://doi.org/10.1007/s10543-015-0574-9">doi:10.1007/s10543-015-0574-9</a>.
*
* @param pax A coordinate
* @param pay A coordinate
Expand All @@ -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);
}

Expand Down