public void transformTest()
        {
            {
                LDQuadTransform quad = new LDQuadTransform(new LDPoint(10, 10), new LDPoint(30, 30));
                LDPoint         src  = new LDPoint(0.5f, 0.25f);

                LDPoint dst = new LDPoint();

                dst = quad.transform(src);

                TestUtil.COMPARE(dst.x(), 20.0);
                TestUtil.COMPARE(dst.y(), 15.0);
            }

            {
                LDQuadTransform quad = new LDQuadTransform(new LDPoint(10, 10), new  LDPoint(20, 10), new LDPoint(100, 100), new LDPoint(10, 20));
                LDPoint         src  = new LDPoint(0.9f, 0.9f);

                LDPoint dst = new LDPoint();

                dst = quad.transform(src);

                //		TestUtil.COMPARE(dst.x(),83.8);
                //		TestUtil.COMPARE(dst.y(),83.8);
                TestUtil.LDFUZZY_COMPARE(dst.x(), 83.8, 0.0000001);
                TestUtil.LDFUZZY_COMPARE(dst.y(), 83.8, 0.0000001);

                //		TestUtil.LDFUZZY_COMPARE(dst.x(),83,0.001);
                //		TestUtil.LDFUZZY_COMPARE(dst.y(),83,0.001);
            }
        }
Exemple #2
0
        /// <summary>
        /// TODO: LDPoint注意
        /// </summary>
        /// <param name="pt"></param>
        /// <param name="clip"></param>
        /// <returns></returns>
        public LDPoint inverseTransform(LDPoint pt, bool clip = false)
        {
            if (getColumn() == 0 && getRow() == 0)
            {
                //メッシュがない場合はそのままの値を返す
                return(pt);
            }

            double x = pt.x();
            double y = pt.y();


            //Gridからマッピング先のQuadを見つける
            LDPoint index = getMapedQuadIndex(new LDPoint((float)x, (float)y));
            int     col   = (int)index.x();
            int     row   = (int)index.y();

            if (clip)
            {
                //Grid内にClipする。QuadをClipして変換するのではない
                col = LDMathUtil.clamp(col, 0, getColumn());
                row = LDMathUtil.clamp(row, 0, getRow());
            }

            LDPoint local = new LDPoint();

            if (isOutside(row, col))
            {
                LDQuadTransform quad = createOutsideQuadTransform(row, col);
                return(quad.inverseTransform(pt, clip));

                //TODO:到達しない場所あります
                local = quad.inverseTransform(pt, clip);

                LDPoint _internal;
                _internal.setX((col + 1) * (1.0f / (getColumn() + 2)) + local.x() / (getColumn() + 2));
                _internal.setY((row + 1) * (1.0f / (getRow() + 2)) + local.y() / (getRow() + 2));

                LDQuadTransform tmp = new LDQuadTransform(new LDPoint(-1, -1), new LDPoint(getColumn() + 1, getRow() + 1));
                return(tmp.transform(_internal));
            }
            else
            {
                LDQuadTransform quad = getQuadTransform(row, col);
                local = quad.inverseTransform(pt, clip);

                LDPoint _internal = new LDPoint();
                _internal.setX(col * (1.0f / getColumn()) + local.x() / getColumn());
                _internal.setY(row * (1.0f / getRow()) + local.y() / getRow());

                return(_internal);
            }
        }
Exemple #3
0
        public LDQuadTransform getOutlineQuadTransform()
        {
            int             rightIndex  = getColumn();
            int             bottomIndex = getRow();
            LDQuadTransform quad        = new LDQuadTransform(
                getPoint(0, 0),
                getPoint(0, rightIndex),
                getPoint(bottomIndex, rightIndex),
                getPoint(bottomIndex, 0));

            return(quad);
        }
Exemple #4
0
        public LDQuadTransform getQuadTransform(int row, int col)
        {
            if (isOutside(row, col))
            {
                Debug.WriteLine("xxx");
            }
            Debug.Assert(!isOutside(row, col));

            LDQuadTransform quad = new LDQuadTransform(
                getPoint(row, col),
                getPoint(row, col + 1),
                getPoint(row + 1, col + 1),
                getPoint(row + 1, col));

            return(quad);
        }
Exemple #5
0
        //時計回りに4点
        public LDGridTransform(LDPoint topLeft, LDPoint topRight, LDPoint bottomRight, LDPoint bottomLeft, int row = 1, int col = 1)
        {
            m_originRect = math.PointUtil.getBoundingRect(new LDPointList { topLeft, topRight, bottomLeft, bottomRight });

            LDQuadTransform quad = new LDQuadTransform(topLeft, topRight, bottomRight, bottomLeft);

            for (int i = 0; i < row + 1; ++i)
            {
                m_gridPoints.Add(new List<LDPoint>());
                for (int j = 0; j < col + 1; ++j)
                {
                    m_gridPoints[i].Add(quad.transform((float)j / col, (float)i / row));
                }
            }

            clearBoundsCache();
        }
Exemple #6
0
        //時計回りに4点
        public LDGridTransform(LDPoint topLeft, LDPoint topRight, LDPoint bottomRight, LDPoint bottomLeft, int row = 1, int col = 1)
        {
            m_originRect = math.PointUtil.getBoundingRect(new LDPointList {
                topLeft, topRight, bottomLeft, bottomRight
            });

            LDQuadTransform quad = new LDQuadTransform(topLeft, topRight, bottomRight, bottomLeft);

            for (int i = 0; i < row + 1; ++i)
            {
                m_gridPoints.Add(new List <LDPoint>());
                for (int j = 0; j < col + 1; ++j)
                {
                    m_gridPoints[i].Add(quad.transform((float)j / col, (float)i / row));
                }
            }

            clearBoundsCache();
        }
        public void rotationTest()
        {
            {
                //(0,0),(100,100)を90度回転
                LDQuadTransform quad = new LDQuadTransform(
                    new LDPoint(100, 0),
                    new LDPoint(100, 100),
                    new LDPoint(0, 100),
                    new LDPoint(0, 0)
                    );
                LDPoint src = new LDPoint(0.5, 0.25);

                LDPoint dst;

                dst = quad.transform(src);

                TestUtil.COMPARE(dst.x(), 75.0);
                TestUtil.COMPARE(dst.y(), 50.0);
            }
            {
                //(0,0),(100,100)を180度回転
                LDQuadTransform quad = new LDQuadTransform(
                    new LDPoint(100, 100),
                    new LDPoint(0, 100),
                    new LDPoint(0, 0),
                    new LDPoint(100, 0)
                    );
                LDPoint src = new LDPoint(0.5, 0.25);

                LDPoint dst;

                dst = quad.transform(src);

                TestUtil.COMPARE(dst.x(), 50.0);
                TestUtil.COMPARE(dst.y(), 75.0);
            }
        }
Exemple #8
0
        //平面上の点を変換した結果を返す。pは基本0..1の範囲
        /// <summary>
        /// TODO:LDPoint注意
        /// </summary>
        /// <param name="t"></param>
        /// <param name="clip"></param>
        /// <returns></returns>
        public LDPoint transform(LDPoint t, bool clip = false)
        {
            if (getColumn() == 0 && getRow() == 0)
            {
                //メッシュがない場合はそのままの値を返す
                return(t);
            }

            double tx = t.x();
            double ty = t.y();

            if (clip)
            {
                //Grid内にClipする。QuadをClipして変換するのではない
                tx = LDMathUtil.clamp(tx, 0.0, 1.0);
                ty = LDMathUtil.clamp(ty, 0.0, 1.0);
            }

            //Gridから対象のQuadを見つける
            LDPoint index = getQuadIndex(new LDPoint((float)tx, (float)ty));
            int     col   = (int)index.x();
            int     row   = (int)index.y();

            LDPoint local = getLocalPoint(new LDPoint((float)tx, (float)ty));

            if (isOutside(row, col))
            {
                LDQuadTransform quad = createOutsideQuadTransform(row, col);
                return(quad.transform(new LDPoint((float)tx, (float)ty)));
            }
            else
            {
                LDQuadTransform quad = getQuadTransform(row, col);
                return(quad.transform(local));
            }
        }
        public void inverseTransformTest()
        {
            {
                LDQuadTransform quad = new LDQuadTransform(new LDPoint(10, 10), new LDPoint(30, 30));
                LDPoint         src  = new LDPoint(20, 15);

                LDPoint dst = new LDPoint();

                dst = quad.inverseTransform(src);

                TestUtil.COMPARE(dst.x(), 0.5);
                TestUtil.COMPARE(dst.y(), 0.25);
            }
            {
                LDQuadTransform quad = new LDQuadTransform(new LDPoint(10, 10), new LDPoint(20, 10), new LDPoint(100, 100), new LDPoint(10, 20));
                LDPoint         src  = new LDPoint(83.8f, 83.8f);

                LDPoint dst;

                dst = quad.inverseTransform(src);
                //		TestUtil.COMPARE(dst.x(),0.9);
                //		TestUtil.COMPARE(dst.y(),0.9);
                TestUtil.LDFUZZY_COMPARE(dst.x(), 0.9, 0.0000001);
                TestUtil.LDFUZZY_COMPARE(dst.y(), 0.9, 0.0000001);
            }
            {
                LDQuadTransform quad = new LDQuadTransform(new LDPoint(10, 10), new LDPoint(30, 30));
                LDPoint         src  = new LDPoint(20, 25);

                LDPoint dst;

                dst = quad.inverseTransform(src);

                TestUtil.COMPARE(dst.x(), 0.5);
                TestUtil.COMPARE(dst.y(), 0.75);
            }
            {
                //(0,0),(100,100)を90度回転
                LDQuadTransform quad = new LDQuadTransform(
                    new LDPoint(100, 0),
                    new LDPoint(100, 100),
                    new LDPoint(0, 100),
                    new LDPoint(0, 0)
                    );
                LDPoint src = new LDPoint(75, 50);

                LDPoint dst;

                dst = quad.inverseTransform(src);
                TestUtil.COMPARE(dst.x(), 0.5);
                TestUtil.COMPARE(dst.y(), 0.25);
            }

            {
                //大きめの数字
                LDQuadTransform quad = new LDQuadTransform(new LDPoint(1024, 1024), new LDPoint(3500, 3500));
                LDPoint         src  = new LDPoint(2000, 2000);

                LDPoint dst;

                dst = quad.inverseTransform(src);

                TestUtil.LDFUZZY_COMPARE(dst.x(), 0.394184, 0.00001);
                TestUtil.LDFUZZY_COMPARE(dst.y(), 0.394184, 0.00001);
            }
            {
                //斜め
                LDQuadTransform quad = new LDQuadTransform(new LDPoint(10, 10), new LDPoint(20, 20), new LDPoint(20, 30), new LDPoint(10, 20));
                LDPoint         src  = new LDPoint(15, 20);

                LDPoint dst;

                dst = quad.inverseTransform(src);

                TestUtil.COMPARE(dst.x(), 0.5);
                TestUtil.COMPARE(dst.y(), 0.5);
            }

            {
                LDQuadTransform quad = new LDQuadTransform(new LDPoint(10.12345f, 10.12321f), new LDPoint(20.1102f, 20.034f), new LDPoint(20.11111f, 30.22222f), new LDPoint(10.232697f, 20.00008f));
                LDPoint         src  = new LDPoint(15.8731f, 20.5396f);

                LDPoint dst;
                LDPoint rest;
                dst  = quad.inverseTransform(src);
                rest = quad.transform(dst);

                TestUtil.LDFUZZY_COMPARE(src.x(), rest.x(), 0.0000001);
                TestUtil.LDFUZZY_COMPARE(src.y(), rest.y(), 0.0000001);
            }
            {
                LDQuadTransform quad = new LDQuadTransform(new LDPoint(1023.12345f, 1041.12321f), new LDPoint(2075.1102, 2032.034), new LDPoint(2034.11111, 3061.22222), new LDPoint(1023.232697, 2088.00008));
                LDPoint         src  = new LDPoint(1515.8731, 2072.5396);

                LDPoint dst;
                LDPoint rest;
                dst  = quad.inverseTransform(src);
                rest = quad.transform(dst);

                TestUtil.LDFUZZY_COMPARE(src.x(), rest.x(), 0.0000001);
                TestUtil.LDFUZZY_COMPARE(src.y(), rest.y(), 0.0000001);
            }
        }
Exemple #10
0
        /// <summary>
        /// TODO: LDPoint注意
        /// </summary>
        /// <param name="pt"></param>
        /// <param name="clip"></param>
        /// <returns></returns>
        public LDPoint inverseTransform(LDPoint pt, bool clip = false)
        {
            if (getColumn() == 0 && getRow() == 0)
            {
                //メッシュがない場合はそのままの値を返す
                return pt;
            }

            double x = pt.x();
            double y = pt.y();

            //Gridからマッピング先のQuadを見つける
            LDPoint index = getMapedQuadIndex(new LDPoint((float)x, (float)y));
            int col = (int)index.x();
            int row = (int)index.y();

            if (clip)
            {
                //Grid内にClipする。QuadをClipして変換するのではない
                col = LDMathUtil.clamp(col, 0, getColumn());
                row = LDMathUtil.clamp(row, 0, getRow());
            }

            LDPoint local = new LDPoint();

            if (isOutside(row, col))
            {
                LDQuadTransform quad = createOutsideQuadTransform(row, col);
                return quad.inverseTransform(pt, clip);

                //TODO:到達しない場所あります
                local = quad.inverseTransform(pt, clip);

                LDPoint _internal=new LDPoint();
                _internal.setX((col + 1) * (1.0f / (getColumn() + 2)) + local.x() / (getColumn() + 2));
                _internal.setY((row + 1) * (1.0f / (getRow() + 2)) + local.y() / (getRow() + 2));

                LDQuadTransform tmp = new LDQuadTransform(new LDPoint(-1, -1), new LDPoint(getColumn() + 1, getRow() + 1));
                return tmp.transform(_internal);
            }
            else
            {
                LDQuadTransform quad = getQuadTransform(row, col);
                local = quad.inverseTransform(pt, clip);

                LDPoint _internal = new LDPoint();
                _internal.setX(col * (1.0f / getColumn()) + local.x() / getColumn());
                _internal.setY(row * (1.0f / getRow()) + local.y() / getRow());

                return _internal;
            }
        }
Exemple #11
0
        public LDQuadTransform getQuadTransform(int row, int col)
        {
            if (isOutside(row, col))
            {
                Debug.WriteLine("xxx");
            }
            Debug.Assert(!isOutside(row, col));

            LDQuadTransform quad = new LDQuadTransform(
                getPoint(row, col),
                getPoint(row, col + 1),
                getPoint(row + 1, col + 1),
                getPoint(row + 1, col));

            return quad;
        }
Exemple #12
0
 public LDQuadTransform getOutlineQuadTransform()
 {
     int rightIndex = getColumn();
     int bottomIndex = getRow();
     LDQuadTransform quad = new LDQuadTransform(
         getPoint(0, 0),
         getPoint(0, rightIndex),
         getPoint(bottomIndex, rightIndex),
         getPoint(bottomIndex, 0));
     return quad;
 }
Exemple #13
0
        public void extendedTransformTest()
        {
            //範囲外補間

            {
                LDQuadTransform quad = new LDQuadTransform(new LDPoint(10, 10), new LDPoint(30, 30));

                LDPoint src = new LDPoint(-1, -1);

                LDPoint dst;

                dst = quad.transform(src);

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

            {
                LDQuadTransform quad = new LDQuadTransform(new LDPoint(10, 10), new LDPoint(30, 30));

                LDPoint src = new LDPoint(-1, -1);

                LDPoint dst;

                dst = quad.transform(src, true);//範囲内にクリッピングする

                TestUtil.COMPARE(dst.x(), 10.0);
                TestUtil.COMPARE(dst.y(), 10.0);
            }

            {
                LDQuadTransform quad = new LDQuadTransform(new LDPoint(10, 10), new LDPoint(30, 30));

                LDPoint src = new LDPoint(2, 2);

                LDPoint dst;

                dst = quad.transform(src);

                TestUtil.COMPARE(dst.x(), 50.0);
                TestUtil.COMPARE(dst.y(), 50.0);
            }

            {
                LDQuadTransform quad = new LDQuadTransform(new LDPoint(10, 10), new LDPoint(30, 30));
                LDPoint         src  = new LDPoint(40, 40);

                LDPoint dst;

                dst = quad.inverseTransform(src);

                TestUtil.COMPARE(dst.x(), 1.5);
                TestUtil.COMPARE(dst.y(), 1.5);
            }

            {
                LDQuadTransform quad = new LDQuadTransform(new LDPoint(10, 10), new LDPoint(30, 30));
                LDPoint         src  = new LDPoint(40, 40);

                LDPoint dst;

                dst = quad.inverseTransform(src, true);

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

            {
                LDQuadTransform quad = new LDQuadTransform(new LDPoint(10.12345, 10.12321), new LDPoint(20.1102, 20.034), new LDPoint(20.11111, 30.22222), new LDPoint(10.232697, 20.00008));
                LDPoint         src  = new LDPoint(45.8731, 60.5396);

                LDPoint dst;
                LDPoint rest;
                dst  = quad.inverseTransform(src);
                rest = quad.transform(dst);

                TestUtil.LDFUZZY_COMPARE(src.x(), rest.x(), 0.0000001);
                TestUtil.LDFUZZY_COMPARE(src.y(), rest.y(), 0.0000001);
            }
            {
                LDQuadTransform quad = new LDQuadTransform(new LDPoint(1023.12345, 1041.12321), new LDPoint(2075.1102, 2032.034), new LDPoint(2034.11111, 3061.22222), new LDPoint(1023.232697, 2088.00008));
                LDPoint         src  = new LDPoint(11515.8731, 62072.5396);

                LDPoint dst;
                LDPoint rest;
                dst  = quad.inverseTransform(src);
                rest = quad.transform(dst);

                TestUtil.LDFUZZY_COMPARE(src.x(), rest.x(), 0.0000001);
                TestUtil.LDFUZZY_COMPARE(src.y(), rest.y(), 0.0000001);
            }
            {
                LDQuadTransform quad = new LDQuadTransform(new LDPoint(1023.12345, 1041.12321), new LDPoint(2075.1102, 2032.034), new LDPoint(2034.11111, 3061.22222), new LDPoint(1023.232697, 2088.00008));
                LDPoint         src  = new LDPoint(5.8731, 72.5396);

                LDPoint dst;
                LDPoint rest;
                dst  = quad.inverseTransform(src);
                rest = quad.transform(dst);

                TestUtil.LDFUZZY_COMPARE(src.x(), rest.x(), 0.0000001);
                TestUtil.LDFUZZY_COMPARE(src.y(), rest.y(), 0.0000001);
            }
        }
Exemple #14
0
        public void inverseTransformTest()
        {
            {
                LDQuadTransform quad=new LDQuadTransform(new LDPoint(10, 10),new LDPoint(30, 30));
                LDPoint src=new LDPoint(20, 15);

                LDPoint dst=new LDPoint();

                dst = quad.inverseTransform(src);

                TestUtil.COMPARE(dst.x(), 0.5);
                TestUtil.COMPARE(dst.y(), 0.25);
            }
            {
                LDQuadTransform quad=new LDQuadTransform(new LDPoint(10, 10), new LDPoint(20, 10), new LDPoint(100, 100), new LDPoint(10, 20));
                LDPoint src=new LDPoint(83.8f, 83.8f);

                LDPoint dst;

                dst = quad.inverseTransform(src);
                //		TestUtil.COMPARE(dst.x(),0.9);
                //		TestUtil.COMPARE(dst.y(),0.9);
                TestUtil.LDFUZZY_COMPARE(dst.x(), 0.9, 0.0000001);
                TestUtil.LDFUZZY_COMPARE(dst.y(), 0.9, 0.0000001);
            }
            {
                LDQuadTransform quad=new LDQuadTransform(new LDPoint(10, 10), new LDPoint(30, 30));
                LDPoint src=new LDPoint(20, 25);

                LDPoint dst;

                dst = quad.inverseTransform(src);

                TestUtil.COMPARE(dst.x(), 0.5);
                TestUtil.COMPARE(dst.y(), 0.75);
            }
            {
                //(0,0),(100,100)を90度回転
                LDQuadTransform quad=new LDQuadTransform(
                           new LDPoint(100, 0),
                           new LDPoint(100, 100),
                           new LDPoint(0, 100),
                           new LDPoint(0, 0)
                            );
                LDPoint src=new LDPoint(75, 50);

                LDPoint dst;

                dst = quad.inverseTransform(src);
                TestUtil.COMPARE(dst.x(), 0.5);
                TestUtil.COMPARE(dst.y(), 0.25);
            }

            {
                //大きめの数字
                LDQuadTransform quad=new LDQuadTransform(new LDPoint(1024, 1024), new LDPoint(3500, 3500));
                LDPoint src=new LDPoint(2000, 2000);

                LDPoint dst;

                dst = quad.inverseTransform(src);

                TestUtil.LDFUZZY_COMPARE(dst.x(), 0.394184, 0.00001);
                TestUtil.LDFUZZY_COMPARE(dst.y(), 0.394184, 0.00001);
            }
            {
                //斜め
                LDQuadTransform quad=new LDQuadTransform(new LDPoint(10, 10),new LDPoint(20, 20),new LDPoint(20, 30),new LDPoint(10, 20));
                LDPoint src=new LDPoint(15, 20);

                LDPoint dst;

                dst = quad.inverseTransform(src);

                TestUtil.COMPARE(dst.x(), 0.5);
                TestUtil.COMPARE(dst.y(), 0.5);
            }

            {
                LDQuadTransform quad=new LDQuadTransform(new LDPoint(10.12345f, 10.12321f),new LDPoint(20.1102f, 20.034f),new LDPoint(20.11111f, 30.22222f), new LDPoint(10.232697f, 20.00008f));
                LDPoint src=new LDPoint(15.8731f, 20.5396f);

                LDPoint dst;
                LDPoint rest;
                dst = quad.inverseTransform(src);
                rest = quad.transform(dst);

                TestUtil.LDFUZZY_COMPARE(src.x(), rest.x(), 0.0000001);
                TestUtil.LDFUZZY_COMPARE(src.y(), rest.y(), 0.0000001);
            }
            {
                LDQuadTransform quad=new LDQuadTransform(new LDPoint(1023.12345f, 1041.12321f),new LDPoint(2075.1102, 2032.034),new LDPoint(2034.11111, 3061.22222),new LDPoint(1023.232697, 2088.00008));
                LDPoint src=new LDPoint(1515.8731, 2072.5396);

                LDPoint dst;
                LDPoint rest;
                dst = quad.inverseTransform(src);
                rest = quad.transform(dst);

                TestUtil.LDFUZZY_COMPARE(src.x(), rest.x(), 0.0000001);
                TestUtil.LDFUZZY_COMPARE(src.y(), rest.y(), 0.0000001);
            }
        }
Exemple #15
0
        public void transformTest()
        {
            {
                LDQuadTransform quad=new LDQuadTransform(new LDPoint(10, 10),new LDPoint(30, 30));
                LDPoint src=new LDPoint(0.5f, 0.25f);

                LDPoint dst=new LDPoint();

                dst = quad.transform(src);

                TestUtil.COMPARE(dst.x(), 20.0);
                TestUtil.COMPARE(dst.y(), 15.0);
            }

            {
                LDQuadTransform quad=new LDQuadTransform(new LDPoint(10, 10),new  LDPoint(20, 10), new LDPoint(100, 100), new LDPoint(10, 20));
                LDPoint src=new LDPoint(0.9f, 0.9f);

                LDPoint dst=new LDPoint();

                dst = quad.transform(src);

                //		TestUtil.COMPARE(dst.x(),83.8);
                //		TestUtil.COMPARE(dst.y(),83.8);
                TestUtil.LDFUZZY_COMPARE(dst.x(), 83.8, 0.0000001);
                TestUtil.LDFUZZY_COMPARE(dst.y(), 83.8, 0.0000001);

                //		TestUtil.LDFUZZY_COMPARE(dst.x(),83,0.001);
                //		TestUtil.LDFUZZY_COMPARE(dst.y(),83,0.001);
            }
        }
Exemple #16
0
        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));
            //	}
        }
Exemple #17
0
        public void rotationTest()
        {
            {
                //(0,0),(100,100)を90度回転
                LDQuadTransform quad=new LDQuadTransform(
                           new LDPoint(100, 0),
                           new LDPoint(100, 100),
                           new LDPoint(0, 100),
                           new LDPoint(0, 0)
                            );
                LDPoint src=new LDPoint(0.5, 0.25);

                LDPoint dst;

                dst = quad.transform(src);

                TestUtil.COMPARE(dst.x(), 75.0);
                TestUtil.COMPARE(dst.y(), 50.0);
            }
            {
                //(0,0),(100,100)を180度回転
                LDQuadTransform quad=new LDQuadTransform(
                           new LDPoint(100, 100),
                           new LDPoint(0, 100),
                           new LDPoint(0, 0),
                           new LDPoint(100, 0)
                            );
                LDPoint src=new LDPoint(0.5, 0.25);

                LDPoint dst;

                dst = quad.transform(src);

                TestUtil.COMPARE(dst.x(), 50.0);
                TestUtil.COMPARE(dst.y(), 75.0);
            }
        }
Exemple #18
0
        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));
            //	}
        }
Exemple #19
-4
        public void extendedTransformTest()
        {
            //範囲外補間

            {
                LDQuadTransform quad=new LDQuadTransform(new LDPoint(10, 10),new LDPoint(30, 30));

                LDPoint src=new LDPoint(-1, -1);

                LDPoint dst;

                dst = quad.transform(src);

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

            {
                LDQuadTransform quad=new LDQuadTransform(new LDPoint(10, 10),new LDPoint(30, 30));

                LDPoint src=new LDPoint(-1, -1);

                LDPoint dst;

                dst = quad.transform(src, true);//範囲内にクリッピングする

                TestUtil.COMPARE(dst.x(), 10.0);
                TestUtil.COMPARE(dst.y(), 10.0);
            }

            {
                LDQuadTransform quad=new LDQuadTransform(new LDPoint(10, 10),new LDPoint(30, 30));

                LDPoint src=new LDPoint(2, 2);

                LDPoint dst;

                dst = quad.transform(src);

                TestUtil.COMPARE(dst.x(), 50.0);
                TestUtil.COMPARE(dst.y(), 50.0);
            }

            {
                LDQuadTransform quad=new LDQuadTransform(new LDPoint(10, 10),new LDPoint(30, 30));
                LDPoint src= new LDPoint(40, 40);

                LDPoint dst;

                dst = quad.inverseTransform(src);

                TestUtil.COMPARE(dst.x(), 1.5);
                TestUtil.COMPARE(dst.y(), 1.5);
            }

            {
                LDQuadTransform quad=new LDQuadTransform(new LDPoint(10, 10),new LDPoint(30, 30));
                LDPoint src=new LDPoint(40, 40);

                LDPoint dst;

                dst = quad.inverseTransform(src, true);

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

            {
                LDQuadTransform quad=new LDQuadTransform(new LDPoint(10.12345, 10.12321), new LDPoint(20.1102, 20.034), new LDPoint(20.11111, 30.22222), new LDPoint(10.232697, 20.00008));
                LDPoint src=new LDPoint(45.8731, 60.5396);

                LDPoint dst;
                LDPoint rest;
                dst = quad.inverseTransform(src);
                rest = quad.transform(dst);

                TestUtil.LDFUZZY_COMPARE(src.x(), rest.x(), 0.0000001);
                TestUtil.LDFUZZY_COMPARE(src.y(), rest.y(), 0.0000001);
            }
            {
                LDQuadTransform quad=new LDQuadTransform(new LDPoint(1023.12345, 1041.12321), new LDPoint(2075.1102, 2032.034), new LDPoint(2034.11111, 3061.22222), new LDPoint(1023.232697, 2088.00008));
                LDPoint src=new LDPoint(11515.8731, 62072.5396);

                LDPoint dst;
                LDPoint rest;
                dst = quad.inverseTransform(src);
                rest = quad.transform(dst);

                TestUtil.LDFUZZY_COMPARE(src.x(), rest.x(), 0.0000001);
                TestUtil.LDFUZZY_COMPARE(src.y(), rest.y(), 0.0000001);
            }
            {
                LDQuadTransform quad=new LDQuadTransform(new LDPoint(1023.12345, 1041.12321), new LDPoint(2075.1102, 2032.034), new LDPoint(2034.11111, 3061.22222), new LDPoint(1023.232697, 2088.00008));
                LDPoint src=new LDPoint(5.8731, 72.5396);

                LDPoint dst;
                LDPoint rest;
                dst = quad.inverseTransform(src);
                rest = quad.transform(dst);

                TestUtil.LDFUZZY_COMPARE(src.x(), rest.x(), 0.0000001);
                TestUtil.LDFUZZY_COMPARE(src.y(), rest.y(), 0.0000001);
            }
        }