예제 #1
0
        public void extendedTransformTest()
        {
            {
                //拡張したGridの取得
                LDGridTransform src = new LDGridTransform(20, 20, 40, 40, 3, 3);
                LDGridTransform dst = src.createExtendedGrid();

                TestUtil.COMPARE(dst.getRow(), 4);
                TestUtil.COMPARE(dst.getColumn(), 4);
                TestUtil.COMPARE(dst.getPoint(0, 0), new LDPoint(-20, -20));
                TestUtil.COMPARE(dst.getPoint(0, 1), new LDPoint(10, -20));
                TestUtil.COMPARE(dst.getPoint(0, 2), new LDPoint(40, -20));
                TestUtil.COMPARE(dst.getPoint(0, 3), new LDPoint(70, -20));
                TestUtil.COMPARE(dst.getPoint(0, 4), new LDPoint(100, -20));
                TestUtil.COMPARE(dst.getPoint(1, 1), new LDPoint(20, 20));
            }

            {
                //範囲外 順変換 クリッピング
                LDGridTransform grid = new LDGridTransform(20, 20, 40, 40, 1, 1);
                LDPoint         src  = new LDPoint(-1, -1);

                LDPoint dst;

                dst = grid.transform(src, true);

                TestUtil.COMPARE(dst.x(), 20.0);
                TestUtil.COMPARE(dst.y(), 20.0);
            }
            {
                //範囲外 順変換
                LDGridTransform grid = new LDGridTransform(20, 20, 40, 40, 1, 1);
                LDPoint         src  = new LDPoint(-1, -1);

                LDPoint dst;

                dst = grid.transform(src);

                TestUtil.COMPARE(dst.x(), -20.0);
                TestUtil.COMPARE(dst.y(), -20.0);
            }
            {
                //範囲外 順変換
                LDGridTransform grid = new LDGridTransform(20, 20, 40, 40, 1, 1);
                LDPoint         src  = new LDPoint(-10, -10);

                LDPoint dst;

                dst = grid.transform(src);

                TestUtil.COMPARE(dst.x(), -380.0);
                TestUtil.COMPARE(dst.y(), -380.0);
            }
            {
                //範囲外 逆変換 クリッピング
                LDGridTransform grid = new LDGridTransform(20, 20, 40, 40, 2, 2);
                LDPoint         src  = new LDPoint(-20, -20);

                LDPoint dst;

                dst = grid.inverseTransform(src, true);

                TestUtil.COMPARE(dst.x(), 0.0);
                TestUtil.COMPARE(dst.y(), 0.0);
            }
            {
                //範囲外 逆変換
                LDGridTransform grid = new LDGridTransform(20, 20, 40, 40, 2, 2);
                LDPoint         src  = new LDPoint(-20, -20);

                LDPoint dst;

                dst = grid.inverseTransform(src);

                TestUtil.COMPARE(dst.x(), -1.0);
                TestUtil.COMPARE(dst.y(), -1.0);
            }

            {
                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(3425.0134623f, 2412.9143f, 5252 - 2412.090023f, 5212 - 2451.00001f, 2, 8);

                LDGridTransform dst = 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(34.0134623f, 24.9143f, 52 - 24.090023f, 52 - 24.00001f, 8, 2);

                LDGridTransform dst = src;

                var points = grid.inverseTransform(src.toForm());
                var rest   = grid.transform(points);

                dst.setForm(points);
                TestUtil.VERIFY(LDMathUtil.fuzzyCompare(rest, src.toForm(), 0.0000001f));
            }
        }
예제 #2
0
        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));
            }
        }
예제 #3
0
        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));
            }
        }