Search in sources :

Example 1 with LineParametric2D_F64

use of georegression.struct.line.LineParametric2D_F64 in project BoofCV by lessthanoptimal.

the class TestRefinePolyLineCorner method distanceSum.

@Test
public void distanceSum() {
    RefinePolyLineCorner alg = new RefinePolyLineCorner(true);
    List<Point2D_I32> contour = new ArrayList<>();
    for (int i = 0; i < 20; i++) {
        contour.add(new Point2D_I32(i, 2));
    }
    LineGeneral2D_F64 line = UtilLine2D_F64.convert(new LineParametric2D_F64(0, 0, 1, 0), (LineGeneral2D_F64) null);
    // normal case
    assertEquals(2 * 16, alg.distanceSum(line, 2, 17, contour), 1e-8);
    // boundary case
    assertEquals(2 * 15, alg.distanceSum(line, 10, 4, contour), 1e-8);
}
Also used : LineGeneral2D_F64(georegression.struct.line.LineGeneral2D_F64) ArrayList(java.util.ArrayList) LineParametric2D_F64(georegression.struct.line.LineParametric2D_F64) Point2D_I32(georegression.struct.point.Point2D_I32) Test(org.junit.Test)

Example 2 with LineParametric2D_F64

use of georegression.struct.line.LineParametric2D_F64 in project BoofCV by lessthanoptimal.

the class TestPolylineSplitMerge method assignLine_parametric.

@Test
public void assignLine_parametric() {
    List<Point2D_I32> contour = new ArrayList<>();
    for (int i = 0; i < 20; i++) {
        contour.add(new Point2D_I32(i, 2));
    }
    // make these points offset from all the others. That way if it grabs the wrong points the line will be wrong
    contour.get(1).set(1, 5);
    contour.get(9).set(9, 5);
    LineParametric2D_F64 line = new LineParametric2D_F64();
    PolylineSplitMerge.assignLine(contour, 1, 9, line);
    assertEquals(0, Distance2D_F64.distanceSq(line, 0, 5), GrlConstants.TEST_F64);
    assertEquals(0, Distance2D_F64.distanceSq(line, 1, 5), GrlConstants.TEST_F64);
    assertEquals(0, Distance2D_F64.distanceSq(line, 9, 5), GrlConstants.TEST_F64);
}
Also used : ArrayList(java.util.ArrayList) LineParametric2D_F64(georegression.struct.line.LineParametric2D_F64) Point2D_I32(georegression.struct.point.Point2D_I32) Test(org.junit.Test)

Aggregations

LineParametric2D_F64 (georegression.struct.line.LineParametric2D_F64)2 Point2D_I32 (georegression.struct.point.Point2D_I32)2 ArrayList (java.util.ArrayList)2 Test (org.junit.Test)2 LineGeneral2D_F64 (georegression.struct.line.LineGeneral2D_F64)1