1.0.0 • Published 8 years ago

point-line-distance v1.0.0

Weekly downloads
287
License
MIT
Repository
github
Last release
8 years ago

point-line-distance

npm Build Status js-standard-style

Computes the distance between a point and a line defined with any two points lying on it

Install

$ npm install --save point-line-distance

Usage

Let

var point = [1, 0, 1]
var a = [1, 2, -1]
var b = [2, 0, 3]

Compute the distance as follows

var pld = require('point-line-distance');
pld(point, a, b)  // Math.sqrt(8 / 7)

If you need the squared distance require squared as follows

var pldSquared = require('point-line-distance/squared');
pldSquared(point, a, b)  // 8 / 7

API

pld = require('point-line-distance')

pld(point, a, b)

params

  • point Array the target point
  • a Array and b Array are two points that define a line

returns

The distance between point and the line defined by a and b

throws

Throws an error when a === b

License

2015 MIT © Mauricio Poppe