exact-segment-intersect
Advanced tools
Comparing version 1.0.0 to 2.0.0
@@ -9,2 +9,3 @@ "use strict" | ||
var compress = require("robust-compress") | ||
var robustIntersect = require("robust-segment-intersect") | ||
@@ -22,2 +23,7 @@ // Find solution to system of two linear equations | ||
function exactIntersect(a, b, c, d) { | ||
if(!robustIntersect(a, b, c, d)) { | ||
return [ [0], [0], [0] ] | ||
} | ||
var x1 = robustSum([c[1]], [-d[1]]) | ||
@@ -33,7 +39,2 @@ var y1 = robustSum([-c[0]], [d[0]]) | ||
//Check denominator | ||
if(denom[0] === 0) { | ||
return [ [0], [0], [0] ] | ||
} | ||
var w0 = robustSum(twoProduct(-a[0], b[1]), twoProduct(a[1], b[0])) | ||
@@ -58,4 +59,4 @@ var w1 = robustSum(twoProduct(-c[0], d[1]), twoProduct(c[1], d[0])) | ||
robustScale(w0, d[1]))) | ||
return [ compress(nX), compress(nY), compress(denom) ] | ||
} | ||
} |
{ | ||
"name": "exact-segment-intersect", | ||
"version": "1.0.0", | ||
"version": "2.0.0", | ||
"description": "Exactly constructs the intersection of two line segments", | ||
@@ -12,4 +12,5 @@ "main": "intersect.js", | ||
"robust-scale": "^1.0.2", | ||
"two-product": "^1.0.2", | ||
"robust-sum": "^1.0.0" | ||
"robust-segment-intersect": "^1.0.1", | ||
"robust-sum": "^1.0.0", | ||
"two-product": "^1.0.2" | ||
}, | ||
@@ -16,0 +17,0 @@ "devDependencies": { |
@@ -1,2 +0,2 @@ | ||
exact-segment-intersection | ||
exact-segment-intersect | ||
========================== | ||
@@ -12,3 +12,3 @@ Exactly computes the intersection of a pair of line segments as a homogeneous vector of non-overlapping increasing sequences. | ||
```javascript | ||
var exactIntersect = require("exact-segment-intersection") | ||
var exactIntersect = require("exact-segment-intersect") | ||
@@ -32,3 +32,3 @@ var a = [-1,0] | ||
``` | ||
npm install exact-segment-intersection | ||
npm install exact-segment-intersect | ||
``` | ||
@@ -38,3 +38,3 @@ | ||
#### `require("exact-segment-intersection")(a,b,c,d)` | ||
#### `require("exact-segment-intersect")(a,b,c,d)` | ||
Exactly computes the intersection of the line segments `[a,b]` and `[c,d]` | ||
@@ -48,2 +48,2 @@ | ||
# Credits | ||
(c) 2014 Mikola Lysenko. MIT License | ||
(c) 2014 Mikola Lysenko. MIT License |
@@ -39,3 +39,3 @@ "use strict" | ||
t.ok(validate(s), "validate s") | ||
t.equals(robustCompare(s, [0]), 0, "check point on line") | ||
@@ -56,3 +56,3 @@ } | ||
var y = computeIntersection( | ||
p[h][s], p[h][s^1], | ||
p[h][s], p[h][s^1], | ||
p[h^1][r], p[h^1][r^1]) | ||
@@ -79,2 +79,11 @@ t.ok(validate(y[0]), "validate x") | ||
t.end() | ||
}) | ||
}) | ||
tape('no isect', function(t) { | ||
var isect = computeIntersection([-1, 10], [-10, 1], [10, 0], [10, 10]); | ||
t.equal(isect[2][0], 0, 'no intersections') | ||
t.end(); | ||
}) |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
7572
118
46
5
+ Addedrobust-orientation@1.2.1(transitive)
+ Addedrobust-segment-intersect@1.0.1(transitive)
+ Addedrobust-subtract@1.0.0(transitive)