Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

polygon-points

Package Overview
Dependencies
Maintainers
1
Versions
15
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

polygon-points

Determine if an x y coordinate exists in a polygon.

  • 0.5.1
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
1.5K
decreased by-2.2%
Maintainers
1
Weekly downloads
 
Created
Source

polygon-points

Build Status Build status GitHub issues GitHub license

Determine if an x y coordinate exists in a polygon. This is being used in a motion detection project where specific regions of an image are being filtered and measured. It works fast when iterating pixels because it caches the bounding box value and uses it to quickly eliminate non-targeted pixels from unnecessary difference calculations. It is designed to be used with positive integer values starting with an x y value of 0 0 at the top left.

installation:

npm install polygon-points --save

usage:

const PP = require('polygon-points');

const polygonPoints = new PP([{x: 0, y: 0}, {x: 0, y: 100}, {x: 100, y: 100}, {x: 100, y: 0}]);

//public methods

//check if a point exists in the polygon
polygonPoints.containsPoint(1, 1);//returns true

//get bounding box of polygon
polygonPoints.boundingBox;//returns an array of 4 x y coordinates

//get total number of points that exist in polygon
polygonPoints.pointsLength;//returns 10000

//set vertexes after creating polygonPoints object
polygonPoints.vertexes = [{x: 0, y: 0}, {x: 0, y: 100}, {x: 100, y: 100}, {x: 100, y: 0}];

Keywords

FAQs

Package last updated on 03 Feb 2018

Did you know?

Socket

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc