use of georegression.struct.shapes.Polygon2D_F64 in project BoofCV by lessthanoptimal.
the class TestSquaresIntoCrossClusters method getCornerIndex.
@Test
public void getCornerIndex() {
SquareNode node = new SquareNode();
node.square = new Polygon2D_F64(4);
node.square.get(0).set(5, 6);
node.square.get(1).set(6, 7);
node.square.get(2).set(7, 8);
node.square.get(3).set(8, 9);
SquaresIntoCrossClusters alg = new SquaresIntoCrossClusters(5, -1);
assertEquals(0, alg.getCornerIndex(node, 5, 6));
assertEquals(1, alg.getCornerIndex(node, 6, 7));
assertEquals(2, alg.getCornerIndex(node, 7, 8));
assertEquals(3, alg.getCornerIndex(node, 8, 9));
}
use of georegression.struct.shapes.Polygon2D_F64 in project BoofCV by lessthanoptimal.
the class TestSquaresIntoRegularClusters method createSquare.
private Polygon2D_F64 createSquare(double x, double y, double yaw, double width) {
Se2_F64 motion = new Se2_F64(x, y, yaw);
double r = width / 2;
Polygon2D_F64 poly = new Polygon2D_F64(4);
poly.get(0).set(-r, r);
poly.get(1).set(r, r);
poly.get(2).set(r, -r);
poly.get(3).set(-r, -r);
for (int i = 0; i < 4; i++) {
SePointOps_F64.transform(motion, poly.get(i), poly.get(i));
}
return poly;
}
use of georegression.struct.shapes.Polygon2D_F64 in project BoofCV by lessthanoptimal.
the class TestSquaresIntoRegularClusters method considerConnect_shape_offset.
/**
* Everything is good, but they are offset from each other by too much
*/
@Test
public void considerConnect_shape_offset() {
List<Polygon2D_F64> squares = new ArrayList<>();
squares.add(new Polygon2D_F64(-1, 1, 1, 1, 1, -1, -1, -1));
squares.add(new Polygon2D_F64(3, 2, 5, 1, 5, -1, 3, -2));
SquaresIntoRegularClusters alg = new SquaresIntoRegularClusters(2, 6, 1.35);
alg.computeNodeInfo(squares);
SquareNode a = alg.nodes.get(0);
SquareNode b = alg.nodes.get(1);
alg.considerConnect(a, b);
assertNotConnected(a, b);
}
use of georegression.struct.shapes.Polygon2D_F64 in project BoofCV by lessthanoptimal.
the class TestSquaresIntoRegularClusters method considerConnect_nominal.
/**
* The usual case. They should attach
*/
@Test
public void considerConnect_nominal() {
List<Polygon2D_F64> squares = new ArrayList<>();
squares.add(new Polygon2D_F64(-1, 1, 1, 1, 1, -1, -1, -1));
squares.add(new Polygon2D_F64(2, 1, 4, 1, 4, -1, 2, -1));
SquaresIntoRegularClusters alg = new SquaresIntoRegularClusters(2, 6, 1.35);
alg.computeNodeInfo(squares);
SquareNode a = alg.nodes.get(0);
SquareNode b = alg.nodes.get(1);
alg.considerConnect(a, b);
// distance is the space between the sides
assertConnected(a, 1, b, 3, 1);
}
use of georegression.struct.shapes.Polygon2D_F64 in project BoofCV by lessthanoptimal.
the class TestSquaresIntoRegularClusters method considerConnect_shape_size.
/**
* Every thing's good, but the size difference of the squares is too much
*/
@Test
public void considerConnect_shape_size() {
List<Polygon2D_F64> squares = new ArrayList<>();
squares.add(new Polygon2D_F64(-1, 1, 1, 1, 1, -1, -1, -1));
squares.add(new Polygon2D_F64(2, 4, 10, 4, 10, -4, 2, -4));
SquaresIntoRegularClusters alg = new SquaresIntoRegularClusters(2, 6, 1.35);
alg.computeNodeInfo(squares);
SquareNode a = alg.nodes.get(0);
SquareNode b = alg.nodes.get(1);
alg.considerConnect(a, b);
assertNotConnected(a, b);
}
Aggregations