Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

red-blue-line-segment-intersect

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

red-blue-line-segment-intersect

Find all intersections between two sets of line segments

  • 1.0.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
2
decreased by-60%
Maintainers
1
Weekly downloads
 
Created
Source

red-blue-line-segment-intersect

Given two sets of line segments, find all pairs of intersections between the two of them.

testling badge

build status

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 ] ] intersect

Install

npm install red-blue-line-segment-intersect

API

require("red-blue-line-segment-intersect")(red, blue, visit)

Finds all pair of segments between red and blue which intersect.

  • red is a list of line segments encoded as pairs of length 2 arrays
  • blue is a second list of line segments
  • visit(r,b) is a function which is called once for each pair of line segments that intersect. If visit returns 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

Keywords

FAQs

Package last updated on 04 Jun 2014

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc