JSPM

point-line-distance

1.0.0
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 1411
  • Score
    100M100P100Q151102F
  • License MIT

3-dimensional point line distance

Package Exports

  • point-line-distance

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (point-line-distance) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

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