Skip to content
 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

gintersect

Finds intersection between two lines. This is JavaScript adaptation of Mukesh Prasad's work from Grapchis Gem II book. It is supposed to be very fast.

See also https://github.com/anvaka/isect a library that finds intersections in a given set of segments

Build Status

usage

var intersect = require('gintersect');
var intersection = intersect(
  // first segment
  -1, 1, // start
  1, -1, // end
  // second segment
  -1, -1, // start
  1, 1 // end
);
console.log(intersection);
// prints {x: 0, y: 0} - intersection point of two segments

If no intersection found return value is falsy:

var parallel = intersect(
  // first segment
  0, 1, // start
  0, 2, // end
  // second segment
  1, 1, // start
  1, 2 // end
);
console.log(parallel);
// prints null - two parallel segments do not intersect.

install

With npm do:

npm install gintersect

license

MIT

About

Finds intersection between two lines

Resources

Code of conduct

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages