@@ -108,12 +108,6 @@ public static int signOfDet2x2(double dx1, double dy1, double dx2, double dy2)
108
108
return det .signum ();
109
109
}
110
110
111
- /**
112
- * A value which is safely greater than the
113
- * relative round-off error in double-precision numbers
114
- */
115
- private static final double DP_SAFE_EPSILON = 1e-15 ;
116
-
117
111
/**
118
112
* A filter for computing the orientation index of three coordinates.
119
113
* <p>
@@ -126,7 +120,8 @@ public static int signOfDet2x2(double dx1, double dy1, double dx2, double dy2)
126
120
* avoid the use of slower robust methods except when they are really needed,
127
121
* thus providing better average performance.
128
122
* <p>
129
- * Uses an approach due to Jonathan Shewchuk, which is in the public domain.
123
+ * Uses an approach due to Ozaki et al., which is published at
124
+ * <a href="https://doi.org/10.1007/s10543-015-0574-9">doi:10.1007/s10543-015-0574-9</a>.
130
125
*
131
126
* @param pax A coordinate
132
127
* @param pay A coordinate
@@ -140,34 +135,12 @@ public static int signOfDet2x2(double dx1, double dy1, double dx2, double dy2)
140
135
private static int orientationIndexFilter (double pax , double pay ,
141
136
double pbx , double pby , double pcx , double pcy )
142
137
{
143
- double detsum ;
144
-
145
138
double detleft = (pax - pcx ) * (pby - pcy );
146
139
double detright = (pay - pcy ) * (pbx - pcx );
147
140
double det = detleft - detright ;
148
141
149
- if (detleft > 0.0 ) {
150
- if (detright <= 0.0 ) {
151
- return signum (det );
152
- }
153
- else {
154
- detsum = detleft + detright ;
155
- }
156
- }
157
- else if (detleft < 0.0 ) {
158
- if (detright >= 0.0 ) {
159
- return signum (det );
160
- }
161
- else {
162
- detsum = -detleft - detright ;
163
- }
164
- }
165
- else {
166
- return signum (det );
167
- }
168
-
169
- double errbound = DP_SAFE_EPSILON * detsum ;
170
- if ((det >= errbound ) || (-det >= errbound )) {
142
+ double errbound = Math .abs (detleft + detright ) * 3.3306690621773714e-16 ;
143
+ if (Math .abs (det ) >= errbound ) {
171
144
return signum (det );
172
145
}
173
146
0 commit comments