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/>.
23 std::vector<RRTNode *> &nodes,
25 float (*cost)(RRTNode *, RRTNode *))
27 RRTNode *root = nodes[0];
28 std::vector<RRTNode *> s; // DFS stack
29 std::vector<RRTNode *> r; // reset visited_
32 float mcost = (*cost)(root, node);
35 while (s.size() > 0) {
40 if ((*cost)(tmp, node) < mcost) {
42 mcost = (*cost)(tmp, node);
44 for (auto ch: tmp->children()) {
56 std::vector<RRTNode *> &nodes,
58 float (*cost)(RRTNode *, RRTNode *))
60 RRTNode *nn = nodes[0];
61 float mcost = (*cost)(nn, node);
63 #pragma omp parallel for
64 for (i = 0; i < nodes.size(); i++) {
65 if ((*cost)(nodes[i], node) < mcost) {
67 mcost = (*cost)(nodes[i], node);
74 std::vector<RRTNode *> (&nodes)[IYSIZE],
76 float (*cost)(RRTNode *, RRTNode *))
78 int iy = floor(node->y() / IYSTEP) + floor(IYSIZE / 2);
79 RRTNode *nn = nullptr;
81 unsigned int i = 0; // vector step
82 unsigned int j = 0; // array step
84 while (mc > j * IYSTEP) {
88 #pragma omp parallel for
89 for (i = 0; i < nodes[iyj].size(); i++) {
90 if ((*cost)(nodes[iyj][i], node) < mc) {
91 mc = (*cost)(nodes[iyj][i], node);
99 #pragma omp parallel for
100 for (i = 0; i < nodes[iyj].size(); i++) {
101 if ((*cost)(nodes[iyj][i], node) < mc) {
102 mc = (*cost)(nodes[iyj][i], node);