2 This file is part of I am car.
4 I am car is free software: you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation, either version 3 of the License, or
7 (at your option) any later version.
9 I am car is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with I am car. If not, see <http://www.gnu.org/licenses/>.
25 RRTNode::RRTNode(float x, float y):
31 RRTNode::RRTNode(float x, float y, float h):
38 float RRTNode::x() const
43 float RRTNode::y() const
48 float RRTNode::h() const
53 float RRTNode::ccost() const
58 float RRTNode::dcost() const
63 std::vector<RRTNode *> &RRTNode::children()
65 return this->children_;
68 RRTNode *RRTNode::parent() const
73 bool RRTNode::visited()
75 return this->visited_;
79 bool RRTNode::add_child(RRTNode *node, float cost)
82 node->ccost(this->ccost() + cost);
84 this->children_.push_back(node);
88 float RRTNode::ccost(float cost)
90 return this->ccost_ = cost;
93 float RRTNode::dcost(float cost)
95 return this->dcost_ = cost;
98 bool RRTNode::parent(RRTNode *parent)
100 if (parent == nullptr)
102 this->parent_ = parent;
106 bool RRTNode::visit(bool v)
108 return this->visited_ = v;
112 bool RRTNode::comp_ccost(RRTNode *n1, RRTNode *n2)
114 return n1->ccost() < n2->ccost();
117 bool RRTNode::visit()
119 if (this->visited_) {
122 this->visited_ = true;