Search in sources :

Example 1 with ScanResultImpl

use of com.robo4j.math.geometry.impl.ScanResultImpl in project robo4j by Robo4J.

the class RaycastTest method testMisbehavingData.

@Disabled("08.09.17 we enable it when it works :)")
@Test
void testMisbehavingData() {
    ScanResultImpl scan = new ScanResultImpl(1.0f, new Predicate<Point2f>() {

        @Override
        public boolean test(Point2f t) {
            return t.getRange() >= 0.08;
        }
    });
    scan.addPoint(Point2f.fromPolar(2.2f, 35.5f));
    scan.addPoint(Point2f.fromPolar(2.2f, 34.5f));
    scan.addPoint(Point2f.fromPolar(2.3f, 33.5f));
    scan.addPoint(Point2f.fromPolar(2.0f, 32.5f));
    scan.addPoint(Point2f.fromPolar(1.9f, 31.5f));
    scan.addPoint(Point2f.fromPolar(1.8f, 30.5f));
    scan.addPoint(Point2f.fromPolar(3.7f, 29.5f));
    scan.addPoint(Point2f.fromPolar(3.8f, 28.5f));
    scan.addPoint(Point2f.fromPolar(2.3f, 27.5f));
    scan.addPoint(Point2f.fromPolar(3.3f, 26.5f));
    scan.addPoint(Point2f.fromPolar(4.2f, 25.5f));
    scan.addPoint(Point2f.fromPolar(3.9f, 24.5f));
    scan.addPoint(Point2f.fromPolar(3.1f, 23.5f));
    scan.addPoint(Point2f.fromPolar(3.7f, 22.5f));
    scan.addPoint(Point2f.fromPolar(3.6f, 21.5f));
    scan.addPoint(Point2f.fromPolar(3.4f, 20.5f));
    scan.addPoint(Point2f.fromPolar(3.3f, 19.5f));
    scan.addPoint(Point2f.fromPolar(3.1f, 18.5f));
    scan.addPoint(Point2f.fromPolar(3.0f, 17.5f));
    scan.addPoint(Point2f.fromPolar(2.8f, 16.5f));
    scan.addPoint(Point2f.fromPolar(2.8f, 15.5f));
    scan.addPoint(Point2f.fromPolar(2.8f, 14.5f));
    scan.addPoint(Point2f.fromPolar(2.8f, 13.5f));
    scan.addPoint(Point2f.fromPolar(2.8f, 12.5f));
    scan.addPoint(Point2f.fromPolar(2.8f, 11.5f));
    scan.addPoint(Point2f.fromPolar(2.9f, 10.5f));
    scan.addPoint(Point2f.fromPolar(2.9f, 9.5f));
    scan.addPoint(Point2f.fromPolar(2.9f, 8.5f));
    scan.addPoint(Point2f.fromPolar(2.9f, 7.5f));
    scan.addPoint(Point2f.fromPolar(2.9f, 6.5f));
    scan.addPoint(Point2f.fromPolar(2.8f, 5.5f));
    scan.addPoint(Point2f.fromPolar(2.7f, 4.5f));
    scan.addPoint(Point2f.fromPolar(2.7f, 3.5f));
    scan.addPoint(Point2f.fromPolar(2.6f, 2.5f));
    scan.addPoint(Point2f.fromPolar(2.6f, 1.5f));
    scan.addPoint(Point2f.fromPolar(2.5f, 0.5f));
    scan.addPoint(Point2f.fromPolar(2.4f, -0.5f));
    scan.addPoint(Point2f.fromPolar(2.4f, -1.5f));
    scan.addPoint(Point2f.fromPolar(2.4f, -2.5f));
    scan.addPoint(Point2f.fromPolar(2.5f, -3.5f));
    scan.addPoint(Point2f.fromPolar(2.5f, -4.5f));
    scan.addPoint(Point2f.fromPolar(3.0f, -5.5f));
    scan.addPoint(Point2f.fromPolar(3.2f, -6.5f));
    scan.addPoint(Point2f.fromPolar(3.2f, -7.5f));
    scan.addPoint(Point2f.fromPolar(3.4f, -8.5f));
    scan.addPoint(Point2f.fromPolar(3.4f, -9.5f));
    scan.addPoint(Point2f.fromPolar(3.5f, -10.5f));
    scan.addPoint(Point2f.fromPolar(3.4f, -11.5f));
    scan.addPoint(Point2f.fromPolar(3.5f, -12.5f));
    scan.addPoint(Point2f.fromPolar(3.4f, -13.5f));
    scan.addPoint(Point2f.fromPolar(3.4f, -14.5f));
    scan.addPoint(Point2f.fromPolar(3.4f, -15.5f));
    scan.addPoint(Point2f.fromPolar(3.3f, -16.5f));
    scan.addPoint(Point2f.fromPolar(3.3f, -17.5f));
    scan.addPoint(Point2f.fromPolar(3.2f, -18.5f));
    scan.addPoint(Point2f.fromPolar(3.2f, -19.5f));
    scan.addPoint(Point2f.fromPolar(3.2f, -20.5f));
    scan.addPoint(Point2f.fromPolar(3.2f, -21.5f));
    scan.addPoint(Point2f.fromPolar(3.1f, -22.5f));
    scan.addPoint(Point2f.fromPolar(3.1f, -23.5f));
    FeatureSet features = FeatureExtraction.getFeatures(scan.getPoints(), 1.0f);
    assertNotNull(features);
    // FIXME: Remove the next two lines when the test is properly fixed.
    assertNotEquals(DELTA, 0);
    assertNotNull(ORIGO);
    Point2f promisingPoint = Raycast.raycastFarthestPoint(scan.getPoints(), 0.4f, 0.3f, features);
    assertNotNull(promisingPoint);
// assertNotEquals(ORIGO.getX(), promisingPoint.getX(), DELTA);
// assertNotEquals(ORIGO.getY(), promisingPoint.getY(), DELTA);
}
Also used : Point2f(com.robo4j.math.geometry.Point2f) ScanResultImpl(com.robo4j.math.geometry.impl.ScanResultImpl) Test(org.junit.jupiter.api.Test) Disabled(org.junit.jupiter.api.Disabled)

Aggregations

Point2f (com.robo4j.math.geometry.Point2f)1 ScanResultImpl (com.robo4j.math.geometry.impl.ScanResultImpl)1 Disabled (org.junit.jupiter.api.Disabled)1 Test (org.junit.jupiter.api.Test)1