Socket
Socket
Sign inDemoInstall

robust-point-in-polygon

Package Overview
Dependencies
6
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    robust-point-in-polygon

Exactly test if a point is inside, outside or on the boundary of a polygon


Version published
Weekly downloads
27K
decreased by-4.94%
Maintainers
1
Install size
48.4 kB
Created
Weekly downloads
 

Readme

Source

robust-point-in-polygon

Exactly determines if a point is contained in a 2D polygon.

Example

var classifyPoint = require("robust-point-in-polygon")
var polygon = [ [ 1, 1 ], [ 1, 2 ], [ 2, 2 ], [ 2, 1 ] ]

console.log(
  classifyPoint(polygon, [1.5, 1.5]),
  classifyPoint(polygon, [1, 2]),
  classifyPoint(polygom, [100000, 10000]))

Output:

-1 0 1

Install

npm install robust-point-in-polygon

API

require("robust-point-in-polygon")(loop, point)

Tests if a point is contained in the interior of a simple polygon

  • loop is an array of vertices for the polygon
  • point is a 2D point which is classified against the polygon

Returns An integer which determines the position of point relative to polygon. This has the following interpretation:

  • -1 if point is contained inside loop
  • 0 if point is on the boundary of loop
  • 1 if point is outside loop

Credits

(c) 2014 Mikola Lysenko. MIT License

Keywords

FAQs

Last updated on 29 Jan 2015

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