Search in sources :

Example 6 with LineSegment2D_F64

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

the class TestSnapToLineEdge method subimage.

public void subimage(Class imageType) {
    setup(null, imageType);
    SnapToLineEdge alg = new SnapToLineEdge(10, 2, imageType);
    alg.setImage(BoofTesting.createSubImageOf_S(image));
    int r = 2;
    LineSegment2D_F64 bottom = new LineSegment2D_F64(x1 - r, y0, x0 + r, y0);
    LineSegment2D_F64 left = new LineSegment2D_F64(x0, y0 + r, x0, y1 - r);
    LineSegment2D_F64 top = new LineSegment2D_F64(x0 + r, y1, x1 - r, y1);
    LineSegment2D_F64 right = new LineSegment2D_F64(x1, y1 - r, x1, y0 + r);
    differentInitial(alg, bottom);
    differentInitial(alg, left);
    differentInitial(alg, top);
    differentInitial(alg, right);
}
Also used : LineSegment2D_F64(georegression.struct.line.LineSegment2D_F64)

Example 7 with LineSegment2D_F64

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

the class TestSquareGraph method findSideIntersect.

@Test
public void findSideIntersect() {
    LineSegment2D_F64 line = new LineSegment2D_F64();
    LineSegment2D_F64 storage = new LineSegment2D_F64();
    SquareNode a = new SquareNode();
    a.square = new Polygon2D_F64(-1, 1, 1, 1, 1, -1, -1, -1);
    SquareGraph alg = new SquareGraph();
    Point2D_F64 intersection = new Point2D_F64();
    line.b.set(0, 2);
    assertEquals(0, alg.findSideIntersect(a, line, intersection, storage));
    line.b.set(0, -2);
    assertEquals(2, alg.findSideIntersect(a, line, intersection, storage));
    line.b.set(2, 0);
    assertEquals(1, alg.findSideIntersect(a, line, intersection, storage));
    line.b.set(-2, 0);
    assertEquals(3, alg.findSideIntersect(a, line, intersection, storage));
}
Also used : LineSegment2D_F64(georegression.struct.line.LineSegment2D_F64) Point2D_F64(georegression.struct.point.Point2D_F64) Polygon2D_F64(georegression.struct.shapes.Polygon2D_F64) Test(org.junit.Test)

Example 8 with LineSegment2D_F64

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

the class TestSnapToLineEdge method differentInitial.

private void differentInitial(SnapToLineEdge alg, LineSegment2D_F64 segment) {
    Vector2D_F64 v = new Vector2D_F64();
    v.x = -segment.slopeY();
    v.y = segment.slopeX();
    v.normalize();
    LineGeneral2D_F64 found = new LineGeneral2D_F64();
    // try
    for (int i = -1; i <= 1; i++) {
        LineSegment2D_F64 work = segment.copy();
        work.a.x += i * v.x;
        work.a.y += i * v.y;
        work.b.x += i * v.x;
        work.b.y += i * v.y;
        assertTrue(alg.refine(work.a, work.b, found));
        checkIdentical(segment, found);
        // do it in the other direction. shouldn't matter
        assertTrue(alg.refine(work.b, work.a, found));
        checkIdentical(segment, found);
    }
}
Also used : LineSegment2D_F64(georegression.struct.line.LineSegment2D_F64) LineGeneral2D_F64(georegression.struct.line.LineGeneral2D_F64) Vector2D_F64(georegression.struct.point.Vector2D_F64)

Aggregations

LineSegment2D_F64 (georegression.struct.line.LineSegment2D_F64)8 LineGeneral2D_F64 (georegression.struct.line.LineGeneral2D_F64)3 Point2D_F64 (georegression.struct.point.Point2D_F64)3 Test (org.junit.Test)3 Polygon2D_F64 (georegression.struct.shapes.Polygon2D_F64)2 ClosestPoint2D_F64 (georegression.metric.ClosestPoint2D_F64)1 Point2D_I32 (georegression.struct.point.Point2D_I32)1 Vector2D_F64 (georegression.struct.point.Vector2D_F64)1 ArrayList (java.util.ArrayList)1