Socket
Socket
Sign inDemoInstall

distance-to-polygon

Package Overview
Dependencies
0
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    distance-to-polygon

Compute distance from a point to an arbitrary shaped polygon, line, or point


Version published
Maintainers
1
Install size
9.10 kB
Created

Readme

Source

distance-to-polygon

Build Status Coverage Status

  • 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 :

    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

Keywords

FAQs

Last updated on 17 Aug 2016

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc