polygon-points
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 = ; const polygonPoints = 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 polygonpolygonPoints;//returns true //get bounding box of polygonpolygonPointsboundingBox;//returns an array of 4 x y coordinates //get total number of points that exist in polygonpolygonPointspointsLength;//returns 10000 //set vertexes after creating polygonPoints objectpolygonPointsvertexes = x: 0 y: 0 x: 0 y: 100 x: 100 y: 100 x: 100 y: 0; //get minX, maxX, minY, and maxY unsigned integers of bounding boxpolygonPointsminX polygonPointsmaxX polygonPointsminY polygonPointsmaxY;