red-blue-line-segment-intersect
v1.0.1
Published
Find all intersections between two sets of line segments
Downloads
15
Maintainers
Readme
red-blue-line-segment-intersect
Given two sets of line segments, find all pairs of intersections between the two of them.
Example
var findIntersections = require("red-blue-line-segment-intersect")
var red = [
[[0, 0], [10, 10]],
[[10, 10], [10, 0]]
]
var blue = [
[[1,0], [1, 8]]
]
findIntersections(red, blue, function(r, b) {
console.log("segments", red[r], blue[b], "intersect")
})Output:
segments [ [ 0, 0 ], [ 10, 10 ] ] [ [ 1, 0 ], [ 1, 8 ] ] intersectInstall
npm install red-blue-line-segment-intersectAPI
require("red-blue-line-segment-intersect")(red, blue, visit)
Finds all pair of segments between red and blue which intersect.
redis a list of line segments encoded as pairs of length 2 arraysblueis a second list of line segmentsvisit(r,b)is a function which is called once for each pair of line segments that intersect. Ifvisitreturns truthy value, then iteration is terminated and that value is returned from the traversal.
Returns The return value of the last call to visit, or undefined otherwise.
Credits
(c) 2013-2014 Mikola Lysenko. MIT License


