private function generateNodes() { $newNodeList = array(); for ($i = 0; $i < count($this->nodes) - 1; $i++) { $length = $this->nodes[$i]->distance($this->nodes[$i + 1]); if ($length > $this->el_max) { // generate new nodes $distance = $length / ceil($length / $this->el_max); // new distance between nodes $element = new Connect(clone $this->nodes[$i], clone $this->nodes[$i], 0, 0); do { $element->increaseLength($distance); array_push($newNodeList, clone $element->endNode); } while ($element->endNode->compare($this->nodes[$i + 1]) == -1); } } foreach ($newNodeList as $n) { $this->addNode($n); } $this->nodes = Node::quickSort($this->nodes); }