The following PHP code uses point in polygon algorithm described at the wikipedia.
In Fig 1 point is in polygon and the line drawn from this crosses the perimeter of the polygon an odd number of times(3). In Fig 2 the line crosses the perimeter an even number of times(4) and the point is outside.
<?php
function pointInPolygon($polySides,$polyX,$polyY,$x,$y) {
$j = $polySides-1 ;
$oddNodes = 0;
for ($i=0; $i<$polySides; $i++) {
if ($polyY[$i]<$y && $polyY[$j]>=$y || $polyY[$j]<$y && $polyY[$i]>=$y) {
if ($polyX[$i]+($y-$polyY[$i])/($polyY[$j]-$polyY[$i])*($polyX[$j]-$polyX[$i])<$x) {
$oddNodes=!$oddNodes;
}
}
$j=$i; }
return $oddNodes;
}
$polySides = 3;
$x =60;
$y =15;
$polyX = array(55.4024447,56.1575776,68.0410163,67.6820048,58.9380148,55.4024447);// First point repeated to close polygon coordinates
$polyY = array(13.1656691,15.8350261,17.4600359,16.1964251,11.3501468,13.1656691);
if (pointInPolygon($polySides,$polyX,$polyY,$x,$y)){
echo "Point In Polygon";
}else{
echo "Point Not In Polygon";
}
?>