- Compilation macros that can specify output binary parameters.
- Auxiliary build and test scripts.
- Nearest neighbour `nn2` procedure based on linear search over `nodes()`.
+- Nearest neighbour `nn3` procedure based on indexing over `y` axis.
## 0.1.0 - 2018-07-05
### Added
}
return nn;
}
+
+RRTNode *nn3(
+ std::vector<RRTNode *> (&nodes)[IYSIZE],
+ RRTNode *node,
+ float (*cost)(RRTNode *, RRTNode *))
+{
+ int iy = floor(node->y() / IYSTEP) + floor(IYSIZE / 2);
+ RRTNode *nn = nullptr;
+ float mc = 9999;
+ unsigned int i = 0; // vector step
+ unsigned int j = 0; // array step
+ int iyj = 0;
+ while (mc > j * IYSTEP) {
+ iyj = (int) (iy + j);
+ if (iyj >= IYSIZE)
+ iyj = IYSIZE - 1;
+ for (i = 0; i < nodes[iyj].size(); i++) {
+ if ((*cost)(nodes[iyj][i], node) < mc) {
+ mc = (*cost)(nodes[iyj][i], node);
+ nn = nodes[iyj][i];
+ }
+ }
+ if (j > 0) {
+ iyj = (int) (iy - j);
+ if (iyj < 0)
+ iyj = 0;
+ for (i = 0; i < nodes[iyj].size(); i++) {
+ if ((*cost)(nodes[iyj][i], node) < mc) {
+ mc = (*cost)(nodes[iyj][i], node);
+ nn = nodes[iyj][i];
+ }
+ }
+ }
+ j++;
+ }
+ return nn;
+}
#ifndef NEARESTNEIGHBOUR_H
#define NEARESTNEIGHBOUR_H
+#include "rrtbase.h"
#include "rrtnode.h"
RRTNode *nn1(
std::vector<RRTNode *> &nodes,
RRTNode *node,
float (*cost)(RRTNode *, RRTNode *));
+RRTNode *nn3(
+ std::vector<RRTNode *> (&nodes)[IYSIZE],
+ RRTNode *node,
+ float (*cost)(RRTNode *, RRTNode *));
#endif