Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ module.exports = function(grunt) {
src : ["src/index.js"],
dest : 'build/decomp.js',
options:{
bundleOptions : {
browserifyOptions : {
standalone : "decomp"
}
}
Expand Down
14 changes: 7 additions & 7 deletions build/decomp.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
!function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var f;"undefined"!=typeof window?f=window:"undefined"!=typeof global?f=global:"undefined"!=typeof self&&(f=self),f.decomp=e()}}(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);throw new Error("Cannot find module '"+o+"'")}var f=n[o]={exports:{}};t[o][0].call(f.exports,function(e){var n=t[o][1][e];return s(n?n:e)},f,f.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(_dereq_,module,exports){
(function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.decomp = f()}})(function(){var define,module,exports;return (function(){function r(e,n,t){function o(i,f){if(!n[i]){if(!e[i]){var c="function"==typeof require&&require;if(!f&&c)return c(i,!0);if(u)return u(i,!0);var a=new Error("Cannot find module '"+i+"'");throw a.code="MODULE_NOT_FOUND",a}var p=n[i]={exports:{}};e[i][0].call(p.exports,function(r){var n=e[i][1][r];return o(n||r)},p,p.exports,r,e,n,t)}return n[i].exports}for(var u="function"==typeof require&&require,i=0;i<t.length;i++)o(t[i]);return o}return r})()({1:[function(require,module,exports){
module.exports = {
decomp: polygonDecomp,
quickDecomp: polygonQuickDecomp,
isSimple: polygonIsSimple,
removeCollinearPoints: polygonRemoveCollinearPoints,
removeDuplicatePoints: polygonRemoveDuplicatePoints,
makeCCW: polygonMakeCCW
makeCCW: polygonMakeCCW,
lineSegmentsIntersect: lineSegmentsIntersect
};

/**
Expand Down Expand Up @@ -117,7 +118,7 @@ function collinear(a,b,c,thresholdAngle) {
var dot = ab[0]*bc[0] + ab[1]*bc[1],
magA = Math.sqrt(ab[0]*ab[0] + ab[1]*ab[1]),
magB = Math.sqrt(bc[0]*bc[0] + bc[1]*bc[1]),
angle = Math.acos(dot/(magA*magB));
angle = Math.acos( Math.min(1, Math.max(0, dot/(magA*magB))) );
return angle < thresholdAngle;
}
}
Expand Down Expand Up @@ -472,7 +473,7 @@ function polygonQuickDecomp(polygon, result,reflexVertices,steinerPoints,delta,m

level++;
if(level > maxlevel){
console.warn("quickDecomp: max level ("+maxlevel+") reached.");
//console.warn("quickDecomp: max level ("+maxlevel+") reached.");
return result;
}

Expand Down Expand Up @@ -657,6 +658,5 @@ function points_eq(a,b,precision){
return scalar_eq(a[0],b[0],precision) && scalar_eq(a[1],b[1],precision);
}

},{}]},{},[1])
(1)
});
},{}]},{},[1])(1)
});
2 changes: 1 addition & 1 deletion build/decomp.min.js

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

12 changes: 6 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,11 @@
"license": "MIT",
"dependencies": {},
"devDependencies": {
"browserify": "^3.44.2",
"grunt": "^1.0.1",
"grunt-browserify": "^2.0.8",
"grunt-contrib-nodeunit": "^1.0.0",
"grunt-contrib-uglify": "^0.4.1",
"nodeunit": "^0.9.1"
"browserify": ">=3.44.2",
"grunt": ">=1.0.1",
"grunt-browserify": ">=2.0.8",
"grunt-contrib-nodeunit": ">=1.0.0",
"grunt-contrib-uglify": ">=0.4.1",
"nodeunit": ">=0.9.5"
}
}
7 changes: 4 additions & 3 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ module.exports = {
isSimple: polygonIsSimple,
removeCollinearPoints: polygonRemoveCollinearPoints,
removeDuplicatePoints: polygonRemoveDuplicatePoints,
makeCCW: polygonMakeCCW
makeCCW: polygonMakeCCW,
lineSegmentsIntersect: lineSegmentsIntersect
};

/**
Expand Down Expand Up @@ -116,7 +117,7 @@ function collinear(a,b,c,thresholdAngle) {
var dot = ab[0]*bc[0] + ab[1]*bc[1],
magA = Math.sqrt(ab[0]*ab[0] + ab[1]*ab[1]),
magB = Math.sqrt(bc[0]*bc[0] + bc[1]*bc[1]),
angle = Math.acos(dot/(magA*magB));
angle = Math.acos( Math.min(1, Math.max(0, dot/(magA*magB))) );
return angle < thresholdAngle;
}
}
Expand Down Expand Up @@ -471,7 +472,7 @@ function polygonQuickDecomp(polygon, result,reflexVertices,steinerPoints,delta,m

level++;
if(level > maxlevel){
console.warn("quickDecomp: max level ("+maxlevel+") reached.");
//console.warn("quickDecomp: max level ("+maxlevel+") reached.");
return result;
}

Expand Down