当前位置: 首页>>代码示例>>PHP>>正文


PHP Node::getY方法代码示例

本文整理汇总了PHP中Node::getY方法的典型用法代码示例。如果您正苦于以下问题:PHP Node::getY方法的具体用法?PHP Node::getY怎么用?PHP Node::getY使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Node的用法示例。


在下文中一共展示了Node::getY方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: convertNode

 /**
  * @param Node $node
  * @return ListNode
  */
 protected function convertNode(Node $node)
 {
     if ($node instanceof ListNode) {
         return $node;
     }
     $listNode = new ListNode($node->getId(), $node->getX(), $node->getY(), 0);
     $listNode->setData($node->getData());
     return $listNode;
 }
开发者ID:tvswe,项目名称:astar,代码行数:13,代码来源:ClosedList.php

示例2: getNeighbors

 /**
  * @param Node $node
  * @param bool $diagonal
  * @return Node[]
  */
 public function getNeighbors(Node $node, $diagonal = false)
 {
     $result = array();
     $x = $node->getX();
     $y = $node->getY();
     $neighbourLocations = [[$y - 1, $x], [$y + 1, $x], [$y, $x - 1], [$y, $x + 1]];
     if ($diagonal) {
         $neighbourLocations[] = [$y - 1, $x - 1];
         $neighbourLocations[] = [$y + 1, $x - 1];
         $neighbourLocations[] = [$y - 1, $x + 1];
         $neighbourLocations[] = [$y + 1, $x + 1];
     }
     foreach ($neighbourLocations as $location) {
         list($y, $x) = $location;
         $node = $this->getPoint($y, $x);
         if ($node) {
             $result[] = $node;
         }
     }
     return $result;
 }
开发者ID:blackscorp,项目名称:astar,代码行数:26,代码来源:Grid.php

示例3: getLinearDistance

 /**
  * @param Node $node1
  * @param Node $node2
  * @return float
  */
 public static function getLinearDistance(Node $node1, Node $node2)
 {
     $dist_x = abs($node1->getX() - $node2->getX());
     $dist_y = abs($node1->getY() - $node2->getY());
     return hypot($dist_x, $dist_y);
 }
开发者ID:tvswe,项目名称:astar,代码行数:11,代码来源:Astar.php

示例4: addControlPoint

 function addControlPoint(Node &$nodeA, Node &$nodeB, Node &$nodeC)
 {
     $midPointBC = array('x' => ($nodeB->getX() + $nodeC->getX()) / 2, 'y' => ($nodeB->getY() + $nodeC->getY()) / 2);
     $cPointX = ($midPointBC['x'] + $nodeA->getX()) / 2;
     $cPointY = ($midPointBC['y'] + $nodeA->getY()) / 2;
     $CPname = $this->addNode($cPointX, $cPointY);
     $this->nodes[$CPname]->addChild($nodeB);
     $this->nodes[$CPname]->addChild($nodeC);
     $this->nodes[$CPname]->setType(Node::N_TYPE_CTRL_POINT);
     return $CPname;
 }
开发者ID:mubasharkk,项目名称:visualize,代码行数:11,代码来源:Cluster_2.php

示例5: getWalkableNeighbors

 public function getWalkableNeighbors(Node $node)
 {
     if (!$node->isWalkable()) {
         return array();
     }
     $deltas = array(array(-1, -1), array(-1, +0), array(-1, +1), array(+0, -1), array(+0, +1), array(+1, -1), array(+1, +0), array(+1, +1));
     $neighbors = array();
     foreach ($deltas as $delta) {
         $x = $node->getX() + $delta[0];
         $y = $node->getY() + $delta[1];
         if ($this->isWalkableAt($x, $y)) {
             $neighbors[] = $this->getNodeAt($x, $y);
         }
     }
     return $neighbors;
 }
开发者ID:letournel,项目名称:path-finder,代码行数:16,代码来源:NodeGrid.php

示例6: connect

 function connect(Node &$nodeA, Node &$nodeB)
 {
     //        $orphan = $nodeB->findClosestOrphan($this->nodes);
     $orphan = $nodeB->findClosest();
     if (!$orphan) {
         return;
     }
     $nodeC =& $this->nodes[$nodeB->findClosest()];
     $dAC = $nodeA->getRelation($nodeC->name);
     $dBC = $nodeB->getRelation($nodeC->name);
     if ($dBC <= $dAC) {
         $midPointBC = array('x' => ($nodeB->getX() + $nodeC->getX()) / 2, 'y' => ($nodeB->getY() + $nodeC->getY()) / 2);
         $cPointX = ($midPointBC['x'] + $nodeA->getX()) / 2;
         $cPointY = ($midPointBC['y'] + $nodeA->getY()) / 2;
         $CPname = $this->addNode($cPointX, $cPointY);
         $this->nodes[$CPname]->addChild($nodeB);
         $this->nodes[$CPname]->addChild($nodeC);
         $this->nodes[$CPname]->setType(Node::N_TYPE_CTRL_POINT);
         $this->sourceNode->addChild($this->nodes[$CPname]);
     }
     if ($this->hasOrphans()) {
         $nextNode = $nodeB->findClosestOrphan($this->nodes);
         $nextNode = $this->nodes[$nextNode];
         if ($nextNode->getRelation($nodeB->name) <= $this->sourceNode->getRelation($nextNode->name) && $nodeB->getChildrenCount() < 2) {
             if ($nodeC->getRelation($nextNode->name) < $nodeB->getRelation($nextNode->name)) {
                 $this->nodes[$nodeC->name]->addChild($nextNode);
             } else {
                 $this->nodes[$nodeB->name]->addChild($nextNode);
             }
         }
     }
     //        if($this->hasOrphans()){
     //            $this->connect($this->nodes[$nodeB->name], $this->nodes[$nodeC->name]);
     //        }
     //        debug_arr($this->sourceNode->getChildren());
     $this->nodes[$nodeA->name] = $nodeA;
 }
开发者ID:mubasharkk,项目名称:visualize,代码行数:37,代码来源:Cluster_1.php

示例7: addControlPoint

 function addControlPoint(Node $nodeA, Node $nodeB)
 {
     $cPointX = ($nodeA->getX() + $nodeB->getX()) / 2;
     $cPointY = ($nodeA->getY() + $nodeB->getY()) / 2;
     $CPname = $this->addNode($cPointX, $cPointY);
     // remove A from dataset
     $this->removeNode($nodeA->name);
     // remove B from dataset
     $this->removeNode($nodeB->name);
     // make A/B children of new control point
     $this->nodes[$CPname]->addChild($nodeA);
     $this->nodes[$CPname]->addChild($nodeB);
     // set new node type as control point
     $this->nodes[$CPname]->setType(Node::N_TYPE_CTRL_POINT);
     $this->rebuildRelationAll();
     $this->connections[$nodeA->name] = $CPname;
     $this->connections[$nodeB->name] = $CPname;
     $this->addToBin($this->nodes[$CPname]);
     return $CPname;
 }
开发者ID:mubasharkk,项目名称:visualize,代码行数:20,代码来源:Cluster.php


注:本文中的Node::getY方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。