本文整理汇总了PHP中Point::anglePolar方法的典型用法代码示例。如果您正苦于以下问题:PHP Point::anglePolar方法的具体用法?PHP Point::anglePolar怎么用?PHP Point::anglePolar使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Point
的用法示例。
在下文中一共展示了Point::anglePolar方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: polygon_finder_recursive
function polygon_finder_recursive(Graph $graph, $currentPolygon, $currentVertex, $lastVertex)
{
// Interdiction path table
// Struct : array[ pointGuid1 ][ pointGuid2 ]
static $pathTable = array();
$polygons = array();
$return = false;
$vertices = $graph->vertices;
$edges = $graph->edges;
if (is_null($lastVertex) || !isset($pathTable[$lastVertex->guid][$currentVertex->guid])) {
// The path loops = area found
if (in_array($currentVertex, $currentPolygon)) {
// Working backward to find the closure point, exclude non-area included vertices
$polygon = new Polygon();
do {
$newPoint = array_pop($currentPolygon);
$polygon->addPoint($newPoint);
} while ($currentVertex != $newPoint);
$currentPolygon = $polygon;
// If the polygon area doesn't include the central point
if ($polygon->includes(reset($vertices)) !== 1) {
// Update the interdiction table
$j = count($currentPolygon) - 1;
for ($k = 0; $k < count($currentPolygon); $k++) {
//$pathTable[ $currentPolygon[ $j ]->guid ][ $currentPolygon[ $k ]->guid ] = true;
$pathTable[$currentPolygon[$k]->guid][$currentPolygon[$j]->guid] = true;
$j++;
if ($j == count($currentPolygon)) {
$j = 0;
}
}
$return = $currentPolygon;
}
} else {
$currentPolygon[] = $currentVertex;
if (is_null($lastVertex)) {
// First point : we search every line from the point
foreach (array_keys($edges[$currentVertex->guid]) as $guid) {
$polygon = polygon_finder_recursive($graph, $currentPolygon, $vertices[$guid], $currentVertex);
if ($polygon !== false) {
$polygonList[] = $polygon;
}
$return = $polygonList;
}
} else {
// Existing line : we follow the first available path with the smallest angle
$angleList = array();
foreach (array_keys($edges[$currentVertex->guid]) as $guid) {
// Stop condition : already passed through here in this direction
if ($lastVertex->guid != $guid && !isset($pathTable[$currentVertex->guid][$vertices[$guid]->guid])) {
$angleList[$guid] = Point::anglePolar($lastVertex, $currentVertex, $vertices[$guid]);
}
}
asort($angleList);
list($guid, $angle) = each($angleList);
if (!is_null($guid)) {
$return = polygon_finder_recursive($graph, $currentPolygon, $vertices[$guid], $currentVertex);
}
}
}
}
return $return;
}