#define GRID_MAX_XI ((unsigned int) floor(GRID_WIDTH / GRID)) // min is 0
#define GRID_MAX_YI ((unsigned int) floor(GRID_HEIGHT / GRID)) // min is 0
+/*! \brief Use grid data structure to store RRT nodes.
+
+This approach speeds up the search process for the nearest neighbor and
+the near vertices procedures.
+*/
+class RRTExt9 : public virtual RRTS {
+ private:
+ class Cell {
+ private:
+ bool changed_ = false;
+ std::vector<RRTNode *> nodes_;
+ public:
+ void nn(RRTNode *t, RRTNode **nn, RRTS *p);
+ void store_node(RRTNode *n);
+
+ // getter, setter
+ bool changed() const
+ {
+ return this->changed_;
+ }
+ std::vector<RRTNode *> &nodes()
+ {
+ return this->nodes_;
+ }
+
+ Cell();
+ };
+ Cell grid_[GRID_MAX_XI][GRID_MAX_YI]; // [0, 0] is bottom left
+ unsigned int x_min_ = 0;
+ unsigned int x_max_ = 0;
+ unsigned int y_min_ = 0;
+ unsigned int y_max_ = 0;
+
+ unsigned int xi(RRTNode n);
+ unsigned int yi(RRTNode n);
+ public:
+ void init();
+ void deinit();
+ void store_node(RRTNode n);
+ RRTNode *nn(RRTNode &t);
+ std::vector<RRTNode *> nv(RRTNode &t);
+};
+
/*! \brief Use k-d tree data structure to store RRT nodes.
This approach speeds up the search process for the nearest neighbor and