Skip to content

Commit

Permalink
- Add test case issue #11
Browse files Browse the repository at this point in the history
  • Loading branch information
alexbol99 committed Jun 12, 2021
1 parent 8a7aa40 commit d7c637d
Show file tree
Hide file tree
Showing 3 changed files with 127 additions and 22 deletions.
61 changes: 41 additions & 20 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,10 @@
"node": ">=4.2.4"
},
"dependencies": {

},
"peerDependencies": {
"@flatten-js/core": "^1.2.16"
"@flatten-js/core": "^1.2.23"
},
"devDependencies": {
"@babel/cli": "^7.2.3",
Expand Down
85 changes: 84 additions & 1 deletion test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -226,5 +226,88 @@ describe('#Algorithms.Offset Polygon', function () {

expect(offsetPolygon.faces.size).to.be.equal(1);
expect(offsetPolygon.edges.size).to.be.equal(8);
})
});
it('Offset sometimes not working Issue #11', () => {
let points = [
[554.4, 420.1],
[637.3, 414.7],
[710.3, 411.7],
[746.5, 408.9],
[782.5, 404.1],
[808.1, 398],
[833.2, 390.2],
[857.7, 381],
[881.6, 370.2],
[903.4, 358.1],
[924.3, 344.6],
[944.4, 330],
[963.8, 314.3],
[992.6, 286.4],
[1019, 256.1],
[1036.8, 233.7],
[1053, 210.2],
[1065.6, 188.6],
[1077, 166.4],
[1108.7, 95.7],
[872.4, 0],
[845.2, 48],
[833.4, 66.9],
[820.3, 84.9],
[801.9, 104.7],
[781.4, 122.6],
[766.8, 132.7],
[751.4, 141.1],
[733.1, 149.2],
[714, 155],
[690.1, 158.5],
[666, 160.2],
[617.5, 161.4],
[554.4, 162.3],
[491.2, 161.4],
[442.8, 160.2],
[418.7, 158.5],
[394.8, 155],
[375.6, 149.2],
[357.3, 141.1],
[341.9, 132.7],
[327.3, 122.6],
[306.8, 104.7],
[288.4, 84.9],
[275.3, 66.9],
[263.5, 48],
[236.4, 0],
[0, 95.7],
[31.7, 166.4],
[43.1, 188.6],
[55.7, 210.2],
[71.9, 233.7],
[89.7, 256.1],
[116.2, 286.4],
[144.9, 314.3],
[164.3, 330],
[184.4, 344.6],
[205.3, 358.1],
[227.1, 370.2],
[251, 381],
[275.5, 390.2],
[300.7, 398],
[326.2, 404.1],
[362.2, 408.9],
[398.4, 411.7],
[471.4, 414.7]
]

for (let scale = 0.3; scale <= 1; scale += 0.025) {
// const scale = 0.6;
const scaledPoints = points.map((pp) => [pp[0] * scale, pp[1] * scale]);

// Calculate offset.
const polygon = new Polygon(scaledPoints);

const offsetPolygon = offset(polygon, -3);

expect(offsetPolygon.faces.size).to.be.equal(1);
}

});
});

0 comments on commit d7c637d

Please sign in to comment.