Skip to content

Commit d7a7ce6

Browse files
committed
make sure hash doesn't change size
1 parent 7666087 commit d7a7ce6

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

index.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,7 @@ export default class Delaunator {
213213
}
214214

215215
_hashKey(x, y) {
216-
return Math.floor(pseudoAngle(x - this._cx, y - this._cy) * this._hashSize);
216+
return Math.floor(pseudoAngle(x - this._cx, y - this._cy) * this._hashSize) % this._hashSize;
217217
}
218218

219219
_legalize(a) {
@@ -312,7 +312,7 @@ export default class Delaunator {
312312
// monotonically increases with real angle, but doesn't need expensive trigonometry
313313
function pseudoAngle(dx, dy) {
314314
const p = dx / (Math.abs(dx) + Math.abs(dy));
315-
return (dy > 0 ? 3 - p : 1 + p) / 4; // [0..1)
315+
return (dy > 0 ? 3 - p : 1 + p) / 4; // [0..1]
316316
}
317317

318318
function dist(ax, ay, bx, by) {

test.js

+1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)