Skip to content

Commit

Permalink
a test for degenerate voronoi
Browse files Browse the repository at this point in the history
  • Loading branch information
Fil authored and mourner committed Aug 30, 2019
1 parent 92506a3 commit 4cf3466
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions test/voronoi-test.js
Expand Up @@ -50,3 +50,10 @@ tape("zero-length edges are removed", test => {
const voronoi2 = Delaunay.from([[10, 10], [20, 10]]).voronoi([0, 0, 30, 20]);
test.deepEqual(voronoi2.cellPolygon(0), [[15, 20], [0, 20], [0, 0], [15, 0], [15, 20]]);
});

tape("a degenerate triangle is avoided", test => {
const pts = [[424.75, 253.75],[424.75, 253.74999999999997],[407.17640687119285, 296.17640687119285],[364.75, 313.75],[322.32359312880715, 296.17640687119285],[304.75, 253.75],[322.32359312880715, 211.32359312880715],[364.75, 193.75],[407.17640687119285, 211.32359312880715],[624.75, 253.75],[607.1764068711929, 296.17640687119285],[564.75, 313.75],[522.3235931288071, 296.17640687119285],[504.75, 253.75],[564.75, 193.75]
]
const voronoi = Delaunay.from(pts).voronoi([10, 10, 960, 500]);
test.equal(voronoi.cellPolygon(0).length, 4);
});

0 comments on commit 4cf3466

Please sign in to comment.