PHP Class Polygon, AlgorithmsNYC

Inheritance: extends Shape
Show file Open project: AlgorithmsNYC/AlgorithmsNYC Class Usage Examples

Protected Properties

Property Type Description
$points

Public Methods

Method Description
__construct ( )
addPoint ( Point $point )
contains ( Point $point )
count ( ) Interface Countable
current ( )
find_polygons_in_graph ( Graph $graph )
getArea ( ) Calculates the area of any given non-crossing polygon
getCentroid ( ) Gets the coordinates of the centroid of the polygon
getPerimeter ( )
includes ( Point $point ) Checks the presence of a point in the polygon Returns : 0 : Point not in polygon 1 : Point in polygon 2 : Point is a node of the polygon
key ( )
next ( )
offsetExists ( $offset )
offsetGet ( $offset )
offsetSet ( $offset, $value ) Interface ArrayAccess
offsetUnset ( $offset )
polygon_finder_recursive ( Graph $graph, $currentPolygon, $currentVertex, $lastVertex )
rewind ( )
valid ( )

Method Details

__construct() public method

public __construct ( )

addPoint() public method

public addPoint ( Point $point )
$point Point

contains() public method

public contains ( Point $point )
$point Point

count() public method

Interface Countable
public count ( )

current() public method

public current ( )

find_polygons_in_graph() public static method

public static find_polygons_in_graph ( Graph $graph )
$graph Graph

getArea() public method

Calculates the area of any given non-crossing polygon
See also: http://www.mathopenref.com/coordpolygonarea2.html
public getArea ( )

getCentroid() public method

Gets the coordinates of the centroid of the polygon
See also: http://stackoverflow.com/questions/2792443/finding-the-centroid-of-a-polygon
public getCentroid ( )

getPerimeter() public method

public getPerimeter ( )

includes() public method

Checks the presence of a point in the polygon Returns : 0 : Point not in polygon 1 : Point in polygon 2 : Point is a node of the polygon
See also: http://stackoverflow.com/questions/217578/point-in-polygon-aka-hit-test
public includes ( Point $point )
$point Point

key() public method

public key ( )

next() public method

public next ( )

offsetExists() public method

public offsetExists ( $offset )

offsetGet() public method

public offsetGet ( $offset )

offsetSet() public method

Interface ArrayAccess
public offsetSet ( $offset, $value )

offsetUnset() public method

public offsetUnset ( $offset )

polygon_finder_recursive() public method

public polygon_finder_recursive ( Graph $graph, $currentPolygon, $currentVertex, $lastVertex )
$graph Graph

rewind() public method

public rewind ( )

valid() public method

public valid ( )

Property Details

$points protected property

protected $points