Skip to content

An algorithm to check that a point is inside or outside the polygon.

Notifications You must be signed in to change notification settings

ermesonqueiroz/point-is-in-polygon

Repository files navigation

Point is in Polygon

The point-is-in-polygon package is a lightweight package that was developed to check if the coordinates of a point are in the coordinates of a polygon.

Usage

import { Point, Polygon } from 'point-is-in-polygon';

const polygon = new Polygon([
  [
    { x: 200, y: 200 },
    { x: 500, y: 100 },
    { x: 800, y: 200 },
    { x: 800, y: 400 },
    { x: 500, y: 500 },
    { x: 200, y: 400 },
    { x: 200, y: 200 },
  ],
]);

const point = new Point({
  x: 300,
  y: 400,
});

point.isInPolygon(polygon); // true

About

An algorithm to check that a point is inside or outside the polygon.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published