Skip to content

Commit cc0108c

Browse files
committed
#2 parity with js: mapbox/delaunator@77a7992
1 parent a23f7cd commit cc0108c

File tree

2 files changed

+11
-5
lines changed

2 files changed

+11
-5
lines changed

include/delaunator.hpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -154,8 +154,8 @@ constexpr double EPSILON = std::numeric_limits<double>::epsilon();
154154
constexpr std::size_t INVALID_INDEX = std::numeric_limits<std::size_t>::max();
155155

156156
inline bool check_pts_equal(double x1, double y1, double x2, double y2) {
157-
return std::fabs(x1 - x2) < EPSILON &&
158-
std::fabs(y1 - y2) < EPSILON;
157+
return std::fabs(x1 - x2) <= EPSILON &&
158+
std::fabs(y1 - y2) <= EPSILON;
159159
}
160160

161161
// monotonically increases with real angle, but doesn't need expensive trigonometry
@@ -344,8 +344,8 @@ Delaunator::Delaunator(std::vector<double> const& in_coords)
344344
const double x = coords[2 * i];
345345
const double y = coords[2 * i + 1];
346346

347-
// skip duplicate points
348-
if (check_pts_equal(x, y, xp, yp)) continue;
347+
// skip near-duplicate points
348+
if (k > 0 && check_pts_equal(x, y, xp, yp)) continue;
349349
xp = x;
350350
yp = y;
351351

0 commit comments

Comments
 (0)