/* * public void serializeTest() * { * string name = "gridMesh"; * LDGridTransform src = new LDGridTransform(0, 0, 100, 100, 2, 2)); * * //シリアライズ * SerializeHelper.writeBoostXml(name, src); * * //デシリアライズ * var dst = SerializeHelper.readBoostXml<LDGridTransform>(name); * * TestUtil.VERIFY(dst->getGridPoints() == src->getGridPoints()); * } */ public void simpleTransformTest() { LDGridTransform grid = new LDGridTransform(20, 20, 40, 40, 1, 1); { LDPoint src = new LDPoint(0.5f, 0.5f); LDPoint dst; dst = grid.transform(src); TestUtil.COMPARE(dst.x(), 40.0); TestUtil.COMPARE(dst.y(), 40.0); } { LDPointList src = new LDPointList(); src.add(new LDPoint(0.25f, 0.25f)).add(new LDPoint(0.75f, 0.75f)); LDPointList dst; dst = grid.transform(src); TestUtil.VERIFY(dst.length() == 2); TestUtil.COMPARE(dst[0], new LDPoint(30.0f, 30)); TestUtil.COMPARE(dst[1], new LDPoint(50.0f, 50)); } { LDGridTransform src = new LDGridTransform(0.5f, 0.5f, 0.5f, 0.5f, 1, 1); LDGridTransform dst = new LDGridTransform(); dst = grid.transform(src); TestUtil.COMPARE(dst.getPoint(0, 0), new LDPoint(40, 40)); TestUtil.COMPARE(dst.getPoint(0, 1), new LDPoint(60, 40)); TestUtil.COMPARE(dst.getPoint(1, 1), new LDPoint(60, 60)); TestUtil.COMPARE(dst.getPoint(1, 0), new LDPoint(40, 60)); } { LDAffineTransform src = new LDAffineTransform(); src.translate(0.5f, 0.5f); src.rotate(30); src.scale(2, 2); LDAffineTransform dst = new LDAffineTransform(); dst = grid.transform(src); TestUtil.COMPARE(dst.getTranslate(), new LDPoint(40, 40)); } }
public void inverseTransformTest() { { LDGridTransform grid = new LDGridTransform(20, 20, 40, 40, 2, 2); LDPoint src = new LDPoint(30, 30); LDPoint dst = new LDPoint(); dst = grid.inverseTransform(src); TestUtil.COMPARE(dst.x(), 0.25); TestUtil.COMPARE(dst.y(), 0.25); } { LDGridTransform grid = new LDGridTransform(20, 20, 40, 40, 2, 2); LDPointList src = new LDPointList(); src.add(new LDPoint(30, 30)).add(new LDPoint(50, 50)); LDPointList dst; dst = grid.inverseTransform(src); TestUtil.COMPARE(dst[0], new LDPoint(0.25f, 0.25f)); TestUtil.COMPARE(dst[1], new LDPoint(0.75f, 0.75f)); } /* * { * LDGridTransform grid = new LDGridTransform(20, 20, 40, 40, 2, 2); * LDGridTransform src = new LDGridTransform(24, 24, 52 - 24, 52 - 24, 2, 2); * * LDGridTransform dst = src; * * var points = grid.inverseTransform(src.toForm()); * * * dst.setForm(points); * LDFUZZY_COMPARE(dst.getPoint(0, 0).x(), 0.1f, 0.0000001f); * LDFUZZY_COMPARE(dst.getPoint(2, 2).x(), 0.8f, 0.0000001f); * LDFUZZY_COMPARE(dst.getPoint(2, 0).x(), 0.1f, 0.0000001f); * LDFUZZY_COMPARE(dst.getPoint(2, 0).y(), 0.8f, 0.0000001f); * } */ { LDGridTransform grid = new LDGridTransform(20.53125f, 20.62423f, 40.614312f, 40.94645f, 2, 2); LDGridTransform src = new LDGridTransform(24.0134623f, 24.9143f, 52 - 24.090023f, 52 - 24.00001f, 2, 2); LDGridTransform dst = new LDGridTransform(src); var points = grid.inverseTransform(src.toForm()); var rest = grid.transform(points); dst.setForm(points); TestUtil.VERIFY(LDMathUtil.fuzzyCompare(rest, src.toForm(), 0.0000001f)); } { LDGridTransform grid = new LDGridTransform(2530.53125f, 2540.62423f, 4015.614312f, 4026.94645f, 2, 2); LDGridTransform src = new LDGridTransform(2594.0134623f, 2594.9143f, 5274 - 2594.090023f, 5276 - 2594.00001f, 2, 2); LDGridTransform dst = new LDGridTransform(src); var points = grid.inverseTransform(src.toForm()); var rest = grid.transform(points); dst.setForm(points); TestUtil.VERIFY(LDMathUtil.fuzzyCompare(rest, src.toForm(), 0.0000001f)); } { LDGridTransform grid = new LDGridTransform( new LDPoint(20.53125f, 20.62423f) , new LDPoint(40.53125f, 20.62423f) , new LDPoint(45.53125f, 45.62423f) , new LDPoint(20.614312f, 40.94645f), 2, 2); LDGridTransform src = new LDGridTransform(34.0134623f, 24.9143f, 52 - 24.090023f, 52 - 24.00001f, 8, 8); LDGridTransform dst = new LDGridTransform(src); var points = grid.inverseTransform(src.toForm()); var rest = grid.transform(points); dst.setForm(points); TestUtil.VERIFY(LDMathUtil.fuzzyCompare(rest, src.toForm(), 0.0000001f)); } { LDGridTransform grid = new LDGridTransform( new LDPoint(2012.53125f, 2051.62423f) , new LDPoint(4097.53125f, 2033.62423f) , new LDPoint(4575.53125f, 4566.62423f) , new LDPoint(2062.614312f, 4000.94645f), 2, 2); LDGridTransform src = new LDGridTransform(3444.0134623f, 2442.9143f, 5242 - 2412.090023f, 5211 - 2467.00001f, 8, 8); LDGridTransform dst = new LDGridTransform(src); var points = grid.inverseTransform(src.toForm()); var rest = grid.transform(points); dst.setForm(points); TestUtil.VERIFY(LDMathUtil.fuzzyCompare(rest, src.toForm(), 0.0000001f)); } }
public void simpleTransformTest() { LDQuadTransform quad = new LDQuadTransform(new LDPoint(10, 10), new LDPoint(30, 30)); { LDPoint src = new LDPoint(0, 0); LDPoint dst; dst = quad.transform(src); TestUtil.COMPARE(dst.x(), 10.0); TestUtil.COMPARE(dst.y(), 10.0); } { LDPoint src = new LDPoint(1, 1); LDPoint dst; dst = quad.transform(src); TestUtil.COMPARE(dst.x(), 30.0); TestUtil.COMPARE(dst.y(), 30.0); } { LDPoint src = new LDPoint(0.5f, 0.25f); LDPoint dst; dst = quad.transform(src); TestUtil.COMPARE(dst.x(), 20.0f); TestUtil.COMPARE(dst.y(), 15.0f); } { LDPoint src = new LDPoint(0.75f, 0.8f); LDPoint dst; dst = quad.transform(src); TestUtil.COMPARE(dst.x(), 25.0f); TestUtil.COMPARE(dst.y(), 26.0f); } { LDPointList src = new LDPointList(); src.add(new LDPoint(0.25f, 0.4f)).add(new LDPoint(0.75f, 0.8f)); LDPointList dst; dst = quad.transform(src); TestUtil.VERIFY(dst.length() == 2); TestUtil.COMPARE(dst[0], new LDPoint(15.0f, 18.0f)); TestUtil.COMPARE(dst[1], new LDPoint(25, 26)); } // { // LDGridTransform src(0.5,0.5,0.5,0.5,1,1); // LDGridTransform dst; // dst=grid.transform(src); // TestUtil.COMPARE(dst.getPoint(0,0),LDPoint(40,40)); // TestUtil.COMPARE(dst.getPoint(0,1),LDPoint(60,40)); // TestUtil.COMPARE(dst.getPoint(1,1),LDPoint(60,60)); // TestUtil.COMPARE(dst.getPoint(1,0),LDPoint(40,60)); // } // { // LDAffineTransform src; // src.translate(0.5,0.5); // src.rotate(30); // src.scale(2,2); // LDAffineTransform dst; // dst=grid.transform(src); // TestUtil.COMPARE(dst.getTranslate(),LDPoint(40,40)); // } }