public void GetKClosestObjectsTest() { QuadTree <TestObject> tree = new QuadTree <TestObject>(m_Bounds); SpacePartitionerTests.GetKClosestObjectsTest(tree); // Now execute tests that will hit all branches of // KNearestNeighbor search method tree.Clear(); tree.Add(new TestObject(490, 499)); tree.Add(new TestObject(501, 499)); tree.Add(new TestObject(499.5f, 501)); tree.Add(new TestObject(501, 501)); tree.Update(); // Uses different orders of child node iteration tree.GetKClosestObjects(new Vector2f(499, 499), 5); tree.GetKClosestObjects(new Vector2f(501, 499), 5); tree.GetKClosestObjects(new Vector2f(499, 501), 5); tree.GetKClosestObjects(new Vector2f(501, 501), 5); // Some objects not in range tree.GetKClosestObjects(new Vector2f(500, 499), 3, 1.001f); // Requires replacing elements in the PQ tree.GetKClosestObjects(new Vector2f(500, 499), 3, 10f); }
public void GetKClosestObjectsTest() { BucketGrid <TestObject> tree = new BucketGrid <TestObject>(m_Bounds, 10, 10); SpacePartitionerTests.GetKClosestObjectsTest(tree); }