pepin82 / geometry
point-in-polygon algorithm
dev-master
2018-02-09 14:01 UTC
Requires
- php: >=5.3.0
Requires (Dev)
- phpunit/phpunit: ~4.0
This package is not auto-updated.
Last update: 2025-04-08 21:42:21 UTC
README
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"; }