public static void checkTransform( List<Point2D_F64> from, List<Point2D_F64> to, Affine2D_F64 tranFound, double tol) { Point2D_F64 foundPt = new Point2D_F64(); for (int i = 0; i < from.size(); i++) { Point2D_F64 p = from.get(i); AffinePointOps.transform(tranFound, p, foundPt); GeometryUnitTest.assertEquals(to.get(i), foundPt, tol); } }
@Test public void noiseless() { Affine2D_F64 tran = new Affine2D_F64(2, -4, 0.3, 1.1, 0.93, -3); List<Point2D_F64> from = UtilPoint2D_F64.random(-10, 10, 30, rand); List<Point2D_F64> to = new ArrayList<Point2D_F64>(); for (Point2D_F64 p : from) { to.add(AffinePointOps.transform(tran, p, null)); } MotionAffinePoint2D_F64 alg = new MotionAffinePoint2D_F64(); assertTrue(alg.process(from, to)); Affine2D_F64 tranFound = alg.getMotion(); checkTransform(from, to, tranFound, GrlConstants.DOUBLE_TEST_TOL); }
@Override public void compute(int x, int y) { AffinePointOps.transform(affine, x, y, tran); distX = tran.x; distY = tran.y; }