use of jcog.tree.rtree.point.Double2D in project narchy by automenta.
the class RTreeNDTest method pointSearchTest.
@Test
public void pointSearchTest() {
final RTree<Double2D> pTree = new RTree<>(new Double2D.Builder(), 2, 8, Spatialization.DefaultSplits.AXIAL);
for (int i = 0; i < 10; i++) {
pTree.add(new Double2D(i, i));
}
final RectDouble2D rect = new RectDouble2D(new Double2D(2, 2), new Double2D(8, 8));
final Double2D[] result = new Double2D[10];
final int n = pTree.containedToArray(rect, result);
assertEquals(7, n);
for (int i = 0; i < n; i++) {
assertTrue(result[i].coord(0) >= 2);
assertTrue(result[i].coord(0) <= 8);
assertTrue(result[i].coord(1) >= 2);
assertTrue(result[i].coord(1) <= 8);
}
}
use of jcog.tree.rtree.point.Double2D in project narchy by automenta.
the class RTree2DTest method pointSearchTest.
@Test
public void pointSearchTest() {
final RTree<Double2D> pTree = new RTree<>(new Double2D.Builder(), 2, 8, Spatialization.DefaultSplits.AXIAL);
for (int i = 0; i < 10; i++) {
pTree.add(new Double2D(i, i));
assertEquals(i + 1, pTree.size());
assertEquals(i + 1, Iterators.size(pTree.iterator()));
}
final RectDouble2D rect = new RectDouble2D(new Double2D(2, 2), new Double2D(8, 8));
final Double2D[] result = new Double2D[10];
final int n = pTree.containedToArray(rect, result);
assertEquals(7, n, () -> Arrays.toString(result));
for (int i = 0; i < n; i++) {
assertTrue(result[i].x >= 2);
assertTrue(result[i].x <= 8);
assertTrue(result[i].y >= 2);
assertTrue(result[i].y <= 8);
}
}
Aggregations