einarsrud/point-in-polygon

Point In Polygon

Installs: 9 343

Dependents: 0

Suggesters: 0

Security: 0

Stars: 1

Watchers: 1

Forks: 0

Open Issues: 0

pkg:composer/einarsrud/point-in-polygon

v1.0.2 2020-10-28 12:26 UTC

This package is not auto-updated.

Last update: 2025-12-19 00:49:34 UTC


README

An implementation of the Winding Number Algorithm. Used to check if a point is inside a polygon.

Installation

Install using Composer

$ composer require einarsrud/point-in-polygon

Usage

// Import the classes
use Raconteur\PointInPolygon\Polygon;
use Raconteur\PointInPolygon\Point;

// Create polygon points
$polygonPoints = [];
$polygonPoints[] = new Point(0, 0);
$polygonPoints[] = new Point(4, 0);
$polygonPoints[] = new Point(2, 4);
$polygonPoints[] = new Point(0, 4);

// Create a Polygon
$polygon = new Polygon($polygonPoints);

// Check if a Point is in a polygon
$pointInPolygon = $polygon->pointInPolygon(new Point(1,1));