pepin82/geometry

point-in-polygon algorithm

dev-master 2018-02-09 14:01 UTC

This package is not auto-updated.

Last update: 2024-04-23 16:54:31 UTC


README

Build Status

Point In Polygon Algorithm, based on Michaël Niessen implementation [http://assemblysys.com/php-point-in-polygon-algorithm/]

Usage

use \Geometry\Point;
use \Geometry\Points;
use \Geometry\Polygon;


$polygon = new Polygon(new Points(array(
    new Point(-1, -1),
    new Point(-1, 1),
    new Point(1, 1),
    new Point(1, -1),
    new Point(-1, -1)
)));

if($polygon->contains(new Point(0, 0))) {
    echo "point is contained in polygon";
}
else {
    echo "point isn't contained in polygon";
}