3 RRTExt7::KdNode::KdNode(RRTNode *n)
10 void RRTExt7::store_node(RRTNode *n, KdNode *&r, int l)
14 else if (l % 2 == 0 && n->x() < r->node()->x())
15 store_node(n, r->left(), l + 1);
17 store_node(n, r->right(), l + 1);
18 else if (l % 2 == 1 && n->y() < r->node()->y())
19 store_node(n, r->left(), l + 1);
21 store_node(n, r->right(), l + 1);
24 void RRTExt7::nn(RRTNode *&n, RRTNode &t, KdNode *r, int l, double &d)
28 if (this->cost_search(*r->node(), t) < d) {
30 d = this->cost_search(*r->node(), t);
32 if (l % 2 == 0 && t.x() < r->node()->x()) {
33 nn(n, t, r->left(), l + 1, d);
34 if (r->node()->x() - t.x() < d)
35 nn(n, t, r->right(), l + 1, d);
36 } else if (l % 2 == 0) {
37 nn(n, t, r->right(), l + 1, d);
38 if (t.x() - r->node()->x() < d)
39 nn(n, t, r->left(), l + 1, d);
40 } else if (l % 2 == 1 && t.y() < r->node()->y()) {
41 nn(n, t, r->left(), l + 1, d);
42 if (r->node()->y() - t.y() < d)
43 nn(n, t, r->right(), l + 1, d);
45 nn(n, t, r->right(), l + 1, d);
46 if (t.y() - r->node()->y() < d)
47 nn(n, t, r->left(), l + 1, d);
56 void RRTExt7::deinit()
60 void RRTExt7::store_node(RRTNode n)
63 RRTNode *sn = &this->nodes().back();
64 this->store_node(sn, this->kdroot_, 0);
67 RRTNode *RRTExt7::nn(RRTNode &t)
69 RRTNode *n = &this->nodes().front();
71 this->nn(n, t, this->kdroot_, 0, d);
75 std::vector<RRTNode *> RRTExt7::nv(RRTNode &t)
77 std::vector<RRTNode *> nv;