point-line-distance
v1.0.0
Published
3-dimensional point line distance
Downloads
1,476
Readme
point-line-distance
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 pointa
[Array] andb
[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