Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/vhf/distance-to-polygon
npm install --save distance-to-polygon
https://github.com/vhf/distance-to-polygon
Last synced: 17 days ago
JSON representation
npm install --save distance-to-polygon
- Host: GitHub
- URL: https://github.com/vhf/distance-to-polygon
- Owner: vhf
- Created: 2016-08-03T12:02:14.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2016-08-17T22:02:35.000Z (about 8 years ago)
- Last Synced: 2024-10-16T19:23:33.928Z (28 days ago)
- Language: JavaScript
- Homepage: https://www.npmjs.com/package/distance-to-polygon
- Size: 10.7 KB
- Stars: 5
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
distance-to-polygon
===================[![Build Status](https://travis-ci.org/vhf/distance-to-polygon.svg?branch=master)](https://travis-ci.org/vhf/distance-to-polygon) [![Coverage Status](https://coveralls.io/repos/github/vhf/distance-to-polygon/badge.svg?branch=master)](https://coveralls.io/github/vhf/distance-to-polygon?branch=master)
* a point `p#` is represented as a list like this : `const p1 = [x = 0, y = 0];`
* `f(x)` is a transformation function applied to the result :```js
const roundToTwoDecimal = (x) => Math.round(x * 100) / 100;
distanceBetweenPoints(p1, p2, roundToTwoDecimal);
```---
* `distanceBetweenPoints(p1, p2, f = (x) => x)`
---
* `distanceToLine(point, line, f = (x) => x)`
* `const line = [p1, p2];`---
For polygons, make sure the vertices are listed clockwise or counter-clockwise.
* `distanceToPolygon(point, vertices, f = (x) => x)`
* `const vertices = [p1, p2, p3, …];`## License
(C) 2016 Victor Felder - MIT License