gintersect

0.1.0 • Public • Published

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.

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

Package Sidebar

Install

npm i gintersect

Weekly Downloads

773

Version

0.1.0

License

MIT

Last publish

Collaborators

  • anvaka