Skip to content

Commit

Permalink
copy array length < 3
Browse files Browse the repository at this point in the history
  • Loading branch information
mattsears18 committed Mar 28, 2019
1 parent 978e23e commit e2f2172
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
7 changes: 4 additions & 3 deletions dist/hull.js
Original file line number Diff line number Diff line change
Expand Up @@ -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));

Expand Down Expand Up @@ -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)));
Expand All @@ -338,14 +338,15 @@ 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;

},{"./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));
Expand Down
8 changes: 4 additions & 4 deletions src/hull.js
Original file line number Diff line number Diff line change
Expand Up @@ -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));

Expand Down Expand Up @@ -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)));
Expand All @@ -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;
module.exports = hull;

0 comments on commit e2f2172

Please sign in to comment.