use of georegression.struct.shapes.Polygon2D_F64 in project BoofCV by lessthanoptimal.
the class TestSquareGridTools method boundingPolygonCCW_row.
@Test
public void boundingPolygonCCW_row() {
SquareGridTools alg = new SquareGridTools();
SquareGrid grid = createGrid(1, 3);
Polygon2D_F64 poly = new Polygon2D_F64(4);
alg.boundingPolygonCCW(grid, poly);
double w = TestSquareRegularClustersIntoGrids.DEFAULT_WIDTH;
assertTrue(poly.get(0).distance(-w / 2, -w / 2) <= 1e-8);
assertTrue(poly.get(1).distance(w * 4 + w / 2, -w / 2) <= 1e-8);
assertTrue(poly.get(2).distance(w * 4 + w / 2, w / 2) <= 1e-8);
assertTrue(poly.get(3).distance(-w / 2, w / 2) <= 1e-8);
}
use of georegression.struct.shapes.Polygon2D_F64 in project BoofCV by lessthanoptimal.
the class TestSquareNode method distanceSqCorner.
@Test
public void distanceSqCorner() {
SquareNode a = new SquareNode();
a.square = new Polygon2D_F64(4);
a.square.get(0).set(-2, -2);
a.square.get(1).set(2, -2);
a.square.get(2).set(2, 2);
a.square.get(3).set(-2, 2);
assertEquals(0, a.distanceSqCorner(new Point2D_F64(-2, -2)), 1e-8);
assertEquals(0, a.distanceSqCorner(new Point2D_F64(2, 2)), 1e-8);
assertEquals(1, a.distanceSqCorner(new Point2D_F64(-3, 2)), 1e-8);
assertEquals(4, a.distanceSqCorner(new Point2D_F64(-4, 2)), 1e-8);
}
use of georegression.struct.shapes.Polygon2D_F64 in project BoofCV by lessthanoptimal.
the class TestSquareNode method getNumberOfConnections.
@Test
public void getNumberOfConnections() {
SquareNode a = new SquareNode();
a.square = new Polygon2D_F64(4);
assertEquals(0, a.getNumberOfConnections());
a.edges[2] = new SquareEdge();
assertEquals(1, a.getNumberOfConnections());
a.edges[0] = new SquareEdge();
assertEquals(2, a.getNumberOfConnections());
a.edges[3] = new SquareEdge();
assertEquals(3, a.getNumberOfConnections());
a.edges[1] = new SquareEdge();
assertEquals(4, a.getNumberOfConnections());
}
use of georegression.struct.shapes.Polygon2D_F64 in project BoofCV by lessthanoptimal.
the class TestSquaresIntoCrossClusters method createSquare.
private DetectPolygonFromContour.Info createSquare(double x, double y) {
DetectPolygonFromContour.Info info = new DetectPolygonFromContour.Info();
info.reset();
info.polygon = new Polygon2D_F64(4);
info.polygon.get(0).set(x, y);
info.polygon.get(1).set(x + 1, y);
info.polygon.get(2).set(x + 1, y - 1);
info.polygon.get(3).set(x, y - 1);
return info;
}
use of georegression.struct.shapes.Polygon2D_F64 in project BoofCV by lessthanoptimal.
the class TestSquaresIntoRegularClusters method disconnectSingleConnections.
@Test
public void disconnectSingleConnections() {
SquaresIntoRegularClusters alg = new SquaresIntoRegularClusters(0.1, 6, 1.35);
alg.nodes.resize(4);
for (int i = 0; i < 4; i++) {
alg.nodes.get(i).square = new Polygon2D_F64(4);
}
SquareNode a = alg.nodes.get(1);
SquareNode b = alg.nodes.get(2);
SquareNode c = alg.nodes.get(3);
SquareNode d = alg.nodes.get(0);
// these will all have two connections
alg.graph.connect(a, 0, b, 0, 2);
alg.graph.connect(a, 1, c, 1, 2);
alg.graph.connect(b, 2, c, 2, 2);
// just one connection
alg.graph.connect(b, 3, d, 2, 2);
alg.disconnectSingleConnections();
for (int i = 1; i < 4; i++) {
assertEquals(2, alg.nodes.get(i).getNumberOfConnections());
}
assertEquals(0, alg.nodes.get(0).getNumberOfConnections());
}
Aggregations