From e2f2172efc11f28609f6e8c843d27db00bba1961 Mon Sep 17 00:00:00 2001 From: mattsears18 Date: Thu, 28 Mar 2019 16:40:43 -0400 Subject: [PATCH] copy array length < 3 --- dist/hull.js | 7 ++++--- src/hull.js | 8 ++++---- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/dist/hull.js b/dist/hull.js index a4bef5f..7aac291 100755 --- a/dist/hull.js +++ b/dist/hull.js @@ -284,7 +284,7 @@ function _concave(convex, maxSqEdgeLen, maxSearchArea, grid, edgeSkipList) { bBoxWidth = bBoxAround[2] - bBoxAround[0]; bBoxHeight = bBoxAround[3] - bBoxAround[1]; - midPoint = _midPoint(edge, grid.rangePoints(bBoxAround), convex); + midPoint = _midPoint(edge, grid.rangePoints(bBoxAround), convex); scaleFactor++; } while (midPoint === null && (maxSearchArea[0] > bBoxWidth || maxSearchArea[1] > bBoxHeight)); @@ -317,7 +317,7 @@ function hull(pointset, concavity, format) { maxEdgeLen = concavity || 20; if (pointset.length < 4) { - return pointset.concat([pointset[0]]); + return pointset.concat([pointset[0]]).slice(); } points = _filterDuplicates(_sortByX(formatUtil.toXy(pointset, format))); @@ -338,7 +338,7 @@ function hull(pointset, concavity, format) { concave = _concave( convex, Math.pow(maxEdgeLen, 2), maxSearchArea, grid(innerPoints, cellSize), {}); - + return formatUtil.fromXy(concave, format); } @@ -346,6 +346,7 @@ var MAX_CONCAVE_ANGLE_COS = Math.cos(90 / (180 / Math.PI)); // angle = 90 deg var MAX_SEARCH_BBOX_SIZE_PERCENT = 0.6; module.exports = hull; + },{"./convex.js":1,"./format.js":2,"./grid.js":3,"./intersect.js":5}],5:[function(require,module,exports){ function ccw(x1, y1, x2, y2, x3, y3) { var cw = ((y3 - y1) * (x2 - x1)) - ((y2 - y1) * (x3 - x1)); diff --git a/src/hull.js b/src/hull.js index fd8f65b..ab3ed70 100644 --- a/src/hull.js +++ b/src/hull.js @@ -139,7 +139,7 @@ function _concave(convex, maxSqEdgeLen, maxSearchArea, grid, edgeSkipList) { bBoxWidth = bBoxAround[2] - bBoxAround[0]; bBoxHeight = bBoxAround[3] - bBoxAround[1]; - midPoint = _midPoint(edge, grid.rangePoints(bBoxAround), convex); + midPoint = _midPoint(edge, grid.rangePoints(bBoxAround), convex); scaleFactor++; } while (midPoint === null && (maxSearchArea[0] > bBoxWidth || maxSearchArea[1] > bBoxHeight)); @@ -172,7 +172,7 @@ function hull(pointset, concavity, format) { maxEdgeLen = concavity || 20; if (pointset.length < 4) { - return pointset.concat([pointset[0]]); + return pointset.concat([pointset[0]]).slice(); } points = _filterDuplicates(_sortByX(formatUtil.toXy(pointset, format))); @@ -193,11 +193,11 @@ function hull(pointset, concavity, format) { concave = _concave( convex, Math.pow(maxEdgeLen, 2), maxSearchArea, grid(innerPoints, cellSize), {}); - + return formatUtil.fromXy(concave, format); } var MAX_CONCAVE_ANGLE_COS = Math.cos(90 / (180 / Math.PI)); // angle = 90 deg var MAX_SEARCH_BBOX_SIZE_PERCENT = 0.6; -module.exports = hull; \ No newline at end of file +module.exports = hull;