MY_TEST(MinAreaRectangleTest, Point) { MY_TEST_RANDOM_STUFF(Point) Vector2List t; t.push_back(Vector2(1,0)); Matrix2Dyn v(2,t.size()); for(unsigned int i = 0; i<t.size(); ++i) { v.col(i) = t[i]; } minRectTest(testName,v); }
MY_TEST(MinAreaRectangleTest, TwoPoints) { MY_TEST_RANDOM_STUFF(TwoPoints) Vector2List v; v.push_back(Vector2(1,0)); v.push_back(Vector2(3,3)); ApproxMVBB::Matrix2Dyn t(2,v.size()); for(unsigned int i = 0; i<v.size(); ++i) { t.col(i) = v[i]; } minRectTest(testName,t); }
MY_TEST(MinAreaRectangleTest, AlmostLine) { MY_TEST_RANDOM_STUFF(AlmostLine) Vector2List v; v.push_back(Vector2(0,0)); v.push_back(Vector2(1,1)); v.push_back(Vector2(1,1+1e-13)); v.push_back(Vector2(2,2)); ApproxMVBB::Matrix2Dyn t(2,v.size()); for(unsigned int i = 0; i<v.size(); ++i) { t.col(i) = v[i]; } minRectTest(testName,t); }
void MazeFinder::GoTo(Vector2 newDestination) { Vector2List pathTest; theSpatialGraph.GetPath(GetPosition(), newDestination, pathTest); if (pathTest.size() > 0) { _pathPoints = pathTest; _pathIndex = 0; GetToNextPoint(); } }
Vector2List getPointsFromFile2D(std::string filePath) { std::ifstream file; // creates stream myFile file.open(filePath.c_str()); // opens .txt file if (!file.is_open()) { // check file is open, quit if not GRSF_ERRORMSG("Could not open file: " << filePath) } PREC a, b; Vector2List v; while (file.good()) { file >> a >> b; v.emplace_back(a, b); } file.close(); std::cout << "Loaded: " << v.size() << " points " << std::endl; return v; }
void SpatialGraphKDNode::Render() { if( HasChildren() ) { LHC->Render(); RHC->Render(); return; } if( theSpatialGraph.GetDrawBlocked() ) { if( bBlocked ) { glColor4f(1,0,0,0.25f); BBox.RenderBox(); } } if( theSpatialGraph.GetDrawBounds() ) { glColor4f(0,0,0,1.f); BBox.RenderOutline(); } Vector2 centroid = BBox.Centroid(); if( theSpatialGraph.GetDrawNodeIndex() ) { Vector2 screenCenter = MathUtil::WorldToScreen( centroid.X, centroid.Y ); //Print some vals glColor3f(0,1.f,1.f); DrawGameText( IntToString(Index), "ConsoleSmall", (unsigned int)screenCenter.X, (unsigned int)screenCenter.Y ); } if( theSpatialGraph.GetDrawGraph() && !bBlocked ) { glColor3f(1.f,0.f,0.f); float linePoints[4]; glEnableClientState(GL_VERTEX_ARRAY); glVertexPointer(2, GL_FLOAT, 0, linePoints); for( unsigned int i = 0; i < Neighbors.size(); i++ ) { if( Neighbors[i]->bBlocked || !NeighborLOS[i] ) continue; //draw centroid to centroid half way point Vector2 neighbor = Neighbors[i]->BBox.Centroid(); neighbor = centroid + ((neighbor - centroid) * 0.6f); linePoints[0] = centroid.X; linePoints[1] = centroid.Y; linePoints[2] = neighbor.X; linePoints[3] = neighbor.Y; glDrawArrays(GL_LINES, 0, 2); } } if( theSpatialGraph.GetDrawGridPoints() ) { glColor3f(1.f,0.f,0.f); Vector2List gridPoints; int xPoints, yPoints; GetGridPoints(gridPoints, xPoints, yPoints ); for( unsigned int i = 0; i < gridPoints.size(); i++ ) { DrawPoint( gridPoints[i], Tree->GetSmallestDimensions().X * 0.15f ); } } }
void test() { using namespace PointFunctions; using namespace TestFunctions; { // generate points ApproxMVBB::Matrix2Dyn t(2,10); t.setRandom(); minRectTest(1,t); } { // generate points Vector2List v; v.push_back(Vector2(0,0)); v.push_back(Vector2(1,1)); v.push_back(Vector2(2,2)); v.push_back(Vector2(3,3)); v.push_back(Vector2(-1,1)); ApproxMVBB::Matrix2Dyn t(2,v.size()); for(unsigned int i = 0; i<v.size(); ++i) { t.col(i) = v[i]; } minRectTest(2,t); } { // generate points Vector2List v; v.push_back(Vector2(0,0)); v.push_back(Vector2(1,1)); v.push_back(Vector2(2,2)); ApproxMVBB::Matrix2Dyn t(2,v.size()); for(unsigned int i = 0; i<v.size(); ++i) { t.col(i) = v[i]; } minRectTest(3,t); } { // generate points Vector2List v; v.push_back(Vector2(0,0)); v.push_back(Vector2(1,1)); ApproxMVBB::Matrix2Dyn t(2,v.size()); for(unsigned int i = 0; i<v.size(); ++i) { t.col(i) = v[i]; } minRectTest(4,t); } { // generate points Vector2List v; v.push_back(Vector2(0,0)); v.push_back(Vector2(1,1)); v.push_back(Vector2(1,-1)); ApproxMVBB::Matrix2Dyn t(2,v.size()); for(unsigned int i = 0; i<v.size(); ++i) { t.col(i) = v[i]; } minRectTest(5,t); } { // generate points Vector2List v; v.push_back(Vector2(0,0)); v.push_back(Vector2(1,1)); v.push_back(Vector2(1,1+1e-13)); v.push_back(Vector2(2,2)); ApproxMVBB::Matrix2Dyn t(2,v.size()); for(unsigned int i = 0; i<v.size(); ++i) { t.col(i) = v[i]; } minRectTest(6,t); } // // { // // generate points on circle // unsigned int max = 100000; // Vector2List v(max); // for(unsigned int i=0; i<max; i++) { // v[i] = Vector2(std::cos(0.0001/max * i) ,std::sin(0.0001/max * i) ); // } // ApproxMVBB::Matrix2Dyn t(2,v.size()); // for(unsigned int i = 0; i<v.size(); ++i) { // t.col(i) = v[i]; // } // minRectTest(7,t); // } { // generate points Vector2List v; v.push_back(Vector2(1,0)); ApproxMVBB::Matrix2Dyn t(2,v.size()); for(unsigned int i = 0; i<v.size(); ++i) { t.col(i) = v[i]; } minRectTest(8,t); } { // generate points Vector2List v; ApproxMVBB::Matrix2Dyn t(2,v.size()); for(unsigned int i = 0; i<v.size(); ++i) { t.col(i) = v[i]; } minRectTest(9,t); } { // generate points Vector2List v; v.push_back(Vector2(0,0)); v.push_back(Vector2(1,0)); v.push_back(Vector2(1,1)); v.push_back(Vector2(0,1)); ApproxMVBB::Matrix2Dyn t(2,v.size()); for(unsigned int i = 0; i<v.size(); ++i) { t.col(i) = v[i]; } minRectTest(10,t); } { // generate points auto v = getPointsFromFile2D("./PointsSimulation2DRectFail.txt"); ApproxMVBB::Matrix2Dyn t(2,v.size()); for(unsigned int i = 0; i<v.size(); ++i) { t.col(i) = v[i]; } minRectTest(11,t); } #ifdef ApproxMVBB_TESTS_HIGH_PERFORMANCE { // generate points ApproxMVBB::Matrix2Dyn t(2,10000000); t.setRandom(); minRectTest(12,t); } #endif { // generate points ApproxMVBB::Matrix2Dyn t(2,400); getPointsFromFileBinary("./PointsBadProjection.bin",t); minRectTest(13,t); } { // generate points ApproxMVBB::Matrix2Dyn t(2,400); getPointsFromFileBinary("./PointsBadProjection2.bin",t); minRectTest(14,t); } { // generate points ApproxMVBB::Matrix2Dyn t(2,400); getPointsFromFileBinary("./PointsBadProjection3.bin",t); minRectTest(15,t); } }