Search in sources :

Example 1 with QuickSort_F64

use of org.ddogleg.sorting.QuickSort_F64 in project BoofCV by lessthanoptimal.

the class TestLlahOperations method findNeighbors.

/**
 * Sees if all the neighbors are found for the specified point. The specified point should not be
 * included in the neighbor list
 */
@Test
void findNeighbors() {
    LlahOperations llahOps = createLlahOps(LlahInvariant.AFFINE);
    List<Point2D_F64> list = UtilPoint2D_F64.random(-1, 1, 20, rand);
    List<Point2D_F64> expected = new ArrayList<>();
    llahOps.nn.setPoints(list, false);
    Point2D_F64 target = list.get(10);
    var distances = new double[list.size()];
    for (int i = 0; i < list.size(); i++) {
        expected.add(list.get(i));
        distances[i] = target.distance(list.get(i));
    }
    new QuickSort_F64().sort(distances, list.size(), expected);
    llahOps.findNeighbors(target);
    for (int i = 0; i < neighborsN; i++) {
        assertTrue(llahOps.neighbors.contains(expected.get(i + 1)));
    }
}
Also used : QuickSort_F64(org.ddogleg.sorting.QuickSort_F64) Point2D_F64(georegression.struct.point.Point2D_F64) UtilPoint2D_F64(georegression.geometry.UtilPoint2D_F64) ArrayList(java.util.ArrayList) Test(org.junit.jupiter.api.Test)

Aggregations

UtilPoint2D_F64 (georegression.geometry.UtilPoint2D_F64)1 Point2D_F64 (georegression.struct.point.Point2D_F64)1 ArrayList (java.util.ArrayList)1 QuickSort_F64 (org.ddogleg.sorting.QuickSort_F64)1 Test (org.junit.jupiter.api.Test)1