]> rtime.felk.cvut.cz Git - hubacji1/iamcar.git/blobdiff - base/nn.cc
Merge branch 'feature/refactor-nn'
[hubacji1/iamcar.git] / base / nn.cc
diff --git a/base/nn.cc b/base/nn.cc
deleted file mode 100644 (file)
index c4e7be5..0000000
+++ /dev/null
@@ -1,69 +0,0 @@
-/*
-This file is part of I am car.
-
-I am car is free software: you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation, either version 3 of the License, or
-(at your option) any later version.
-
-I am car is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with I am car. If not, see <http://www.gnu.org/licenses/>.
-*/
-
-# include <vector>
-# include "nn.h"
-
-RRTNode *nn1(
-                std::vector<RRTNode *> &nodes,
-                RRTNode *node,
-                float (*cost)(RRTNode *, RRTNode *))
-{
-        RRTNode *root = nodes[0];
-        std::vector<RRTNode *> s; // DFS stack
-        std::vector<RRTNode *> r; // reset visited_
-        RRTNode *tmp;
-        RRTNode *nn = root;
-        float mcost = (*cost)(root, node);
-
-        s.push_back(root);
-        while (s.size() > 0) {
-                tmp = s.back();
-                s.pop_back();
-                if (!tmp->visit()) {
-                        r.push_back(tmp);
-                        if ((*cost)(tmp, node) < mcost) {
-                                nn = tmp;
-                                mcost = (*cost)(tmp, node);
-                        }
-                        for (auto ch: tmp->children()) {
-                                s.push_back(ch);
-                        }
-                }
-        }
-        for (auto n: r) {
-                n->visit(false);
-        }
-        return nn;
-}
-
-RRTNode *nn2(
-                std::vector<RRTNode *> &nodes,
-                RRTNode *node,
-                float (*cost)(RRTNode *, RRTNode *))
-{
-        RRTNode *nn = nodes[0];
-        float mcost = (*cost)(nn, node);
-        unsigned int i;
-        for (i = 0; i < nodes.size(); i++) {
-                if ((*cost)(nodes[i], node) < mcost) {
-                        nn = nodes[i];
-                        mcost = (*cost)(nodes[i], node);
-                }
-        }
-        return nn;
-}