///<summary>
        /// Checks that a transformation produces the expected result
        ///</summary>
        /// <param name="x">the input pt x</param>
        /// <param name="y">the input pt y</param>
        /// <param name="trans">the transformation</param>
        /// <param name="xp">the expected output x</param>
        /// <param name="yp">the expected output y</param>
        static void CheckTransformation(double x, double y, AffineTransformation trans, double xp, double yp)
        {
            var p  = new Coordinate(x, y);
            var p2 = new Coordinate();

            trans.Transform(p, p2);
            Assert.AreEqual(xp, p2.X, .00005);
            Assert.AreEqual(yp, p2.Y, .00005);

            // if the transformation is invertible, test the inverse
            try
            {
                var invTrans = trans.GetInverse();
                var pInv     = new Coordinate();
                invTrans.Transform(p2, pInv);
                Assert.AreEqual(x, pInv.X, .00005);
                Assert.AreEqual(y, pInv.Y, .00005);

                double det    = trans.Determinant;
                double detInv = invTrans.Determinant;
                Assert.AreEqual(det, 1.0 / detInv, .00005);
            }
            catch (NoninvertibleTransformationException)
            {
            }
        }
예제 #2
0
            public AffineTransform(AffineTransformation affineTransformation)
            {
                _affineTransformation        = affineTransformation;
                _inverseAffineTransformation = affineTransformation.GetInverse();
                _transformation = affineTransformation;

                DimSource = DimTarget = 2;
                //WKT = "NTS AffineTransformation";
            }
            public AffineTransform(AffineTransformation affineTransformation)
            {
                _affineTransformation = affineTransformation;
                _inverseAffineTransformation = affineTransformation.GetInverse();
                _transformation = affineTransformation;

                DimSource = DimTarget = 2;
                //WKT = "NTS AffineTransformation";
            }
        static void CheckTransformation(String geomStr)
        {
            Geometry             geom  = (Geometry)WktReader.Read(geomStr);
            AffineTransformation trans = AffineTransformation
                                         .RotationInstance(Math.PI / 2);
            AffineTransformation inv       = trans.GetInverse();
            Geometry             transGeom = (Geometry)geom.Clone();

            transGeom.Apply(trans);
            // System.out.println(transGeom);
            transGeom.Apply(inv);
            // check if transformed geometry is equal to original
            bool isEqual = geom.EqualsExact(transGeom, 0.0005);

            Assert.IsTrue(isEqual);
        }
        ///<summary>
        /// Checks that a transformation produces the expected result
        ///</summary>
        /// <param name="x">the input pt x</param>
        /// <param name="y">the input pt y</param>
        /// <param name="trans">the transformation</param>
        /// <param name="xp">the expected output x</param>
        /// <param name="yp">the expected output y</param>
        static void CheckTransformation(double x, double y, AffineTransformation trans, double xp, double yp)
        {
            Coordinate p = new Coordinate(x, y);
            Coordinate p2 = new Coordinate();
            trans.Transform(p, p2);
            Assert.AreEqual(xp, p2.X, .00005);
            Assert.AreEqual(yp, p2.Y, .00005);

            // if the transformation is invertible, test the inverse
            try
            {
                AffineTransformation invTrans = trans.GetInverse();
                Coordinate pInv = new Coordinate();
                invTrans.Transform(p2, pInv);
                Assert.AreEqual(x, pInv.X, .00005);
                Assert.AreEqual(y, pInv.Y, .00005);

                double det = trans.Determinant;
                double detInv = invTrans.Determinant;
                Assert.AreEqual(det, 1.0 / detInv, .00005);

            }
            catch (NoninvertibleTransformationException)
            {
            }
        }