added several grid-walks
added new helper methods/classes (e.g. for heading) new test cases optimize the dijkstra cleanups/refactoring added timed-benchmarks to the log many more...
This commit is contained in:
43
tests/misc/TestKNN.cpp
Normal file
43
tests/misc/TestKNN.cpp
Normal file
@@ -0,0 +1,43 @@
|
||||
#ifdef WITH_TESTS
|
||||
|
||||
#include "../Tests.h"
|
||||
|
||||
#include <vector>
|
||||
#include "../../misc/KNN.h"
|
||||
#include "../../misc/KNNArray.h"
|
||||
#include "../../geo/Point3.h"
|
||||
|
||||
/** test knn-search using the array-wrapper */
|
||||
TEST(KNN, array) {
|
||||
|
||||
// construct 3D cross
|
||||
std::vector<Point3> points;
|
||||
|
||||
for (int x = -10; x <= 10; ++x) { if (0 == x) {continue;} points.push_back(Point3(x,0,0)); } // idx 0 - 19
|
||||
for (int y = -10; y <= 10; ++y) { if (0 == y) {continue;} points.push_back(Point3(0,y,0)); } // idx 20 - 39
|
||||
for (int z = -10; z <= 10; ++z) { if (0 == z) {continue;} points.push_back(Point3(0,0,z)); } // idx 40 - 59
|
||||
points.push_back(Point3(0,0,0)); // idx 60
|
||||
|
||||
// construct KNN search
|
||||
KNNArray<std::vector<Point3>> arr(points);
|
||||
KNN<KNNArray<std::vector<Point3>>, 3> knn(arr);
|
||||
|
||||
// test center
|
||||
ASSERT_EQ(60, knn.getNearestIndex({0,0,0}) );
|
||||
|
||||
// test X min/max
|
||||
ASSERT_EQ(0, knn.getNearestIndex({-20,0,0}) );
|
||||
ASSERT_EQ(19, knn.getNearestIndex({20,0,0}) );
|
||||
|
||||
// test Y min/max
|
||||
ASSERT_EQ(20, knn.getNearestIndex({0,-20,0}) );
|
||||
ASSERT_EQ(39, knn.getNearestIndex({0,20,0}) );
|
||||
|
||||
// test Z min/max
|
||||
ASSERT_EQ(40, knn.getNearestIndex({0,0,-20}) );
|
||||
ASSERT_EQ(59, knn.getNearestIndex({0,0,20}) );
|
||||
|
||||
}
|
||||
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user