コード例 #1
0
 /// <summary>
 /// Creates a tranformation from a set of three control vectors. A control
 /// vector consists of a source point and a destination point, which is the
 /// image of the source point under the desired transformation. Three control
 /// vectors allows defining a fully general affine transformation.
 /// </summary>
 /// <param name="src0"></param>
 /// <param name="src1"></param>
 /// <param name="src2"></param>
 /// <param name="dest0"></param>
 /// <param name="dest1"></param>
 /// <param name="dest2"></param>
 /// <returns>The computed transformation</returns>
 public static AffineTransformation CreateFromControlVectors(Coordinate src0,
         Coordinate src1, Coordinate src2, Coordinate dest0, Coordinate dest1,
         Coordinate dest2)
 {
     AffineTransformationBuilder builder = new AffineTransformationBuilder(src0,
             src1, src2, dest0, dest1, dest2);
     return builder.GetTransformation();
 }
コード例 #2
0
        /// <summary>
        /// Creates a transformation from a set of three control vectors. A control
        /// vector consists of a source point and a destination point, which is the
        /// image of the source point under the desired transformation. Three control
        /// vectors allows defining a fully general affine transformation.
        /// </summary>
        /// <param name="src0"></param>
        /// <param name="src1"></param>
        /// <param name="src2"></param>
        /// <param name="dest0"></param>
        /// <param name="dest1"></param>
        /// <param name="dest2"></param>
        /// <returns>The computed transformation</returns>
        public static AffineTransformation CreateFromControlVectors(Coordinate src0,
                                                                    Coordinate src1, Coordinate src2, Coordinate dest0, Coordinate dest1,
                                                                    Coordinate dest2)
        {
            var builder = new AffineTransformationBuilder(src0,
                                                          src1, src2, dest0, dest1, dest2);

            return(builder.GetTransformation());
        }
コード例 #3
0
        private static AffineTransformation ReadKnotenListe(string file)
        {
            int index = 0;
            Coordinate[] src = new Coordinate[3];
            Coordinate[] dst = new Coordinate[3];
            using (StreamReader sr = new StreamReader(File.OpenRead(file)))
            {
                while (!sr.EndOfStream)
                {
                    string line = sr.ReadLine();
                    if (string.IsNullOrEmpty(line)) continue;
                    if (line.StartsWith("#")) continue;

                    src[index] = new Coordinate(double.Parse(line.Substring(15, 11), NumberFormatInfo.InvariantInfo),
                                                double.Parse(line.Substring(26, 11), NumberFormatInfo.InvariantInfo));
                    dst[index] = new Coordinate(double.Parse(line.Substring(37, 11), NumberFormatInfo.InvariantInfo),
                                                double.Parse(line.Substring(48, 11), NumberFormatInfo.InvariantInfo));
                    index++;
                    if (index == 3) break;
                }
            }
            AffineTransformationBuilder atb = new AffineTransformationBuilder(src[0], src[1], src[2], dst[0], dst[1], dst[2]);
            return atb.GetTransformation();
        }
コード例 #4
0
        static void Run(double p0x, double p0y,
            double p1x, double p1y,
            double p2x, double p2y,
            double pp0x, double pp0y,
            double pp1x, double pp1y,
            double pp2x, double pp2y
            )
        {
            Coordinate p0 = new Coordinate(p0x, p0y);
            Coordinate p1 = new Coordinate(p1x, p1y);
            Coordinate p2 = new Coordinate(p2x, p2y);

            Coordinate pp0 = new Coordinate(pp0x, pp0y);
            Coordinate pp1 = new Coordinate(pp1x, pp1y);
            Coordinate pp2 = new Coordinate(pp2x, pp2y);

            AffineTransformationBuilder atb = new AffineTransformationBuilder(
                p0, p1, p2,
                pp0, pp1, pp2);
            AffineTransformation trans = atb.GetTransformation();

            Coordinate dest = new Coordinate();
            AssertEqualPoint(pp0, trans.Transform(p0, dest));
            AssertEqualPoint(pp1, trans.Transform(p1, dest));
            AssertEqualPoint(pp2, trans.Transform(p2, dest));
        }
コード例 #5
0
        private static void RunTransform(AffineTransformation trans,
            Coordinate p0,
            Coordinate p1,
            Coordinate p2)
        {
            Coordinate pp0 = trans.Transform(p0, new Coordinate());
            Coordinate pp1 = trans.Transform(p1, new Coordinate());
            Coordinate pp2 = trans.Transform(p2, new Coordinate());

            AffineTransformationBuilder atb = new AffineTransformationBuilder(
                p0, p1, p2,
                pp0, pp1, pp2);
            AffineTransformation atbTrans = atb.GetTransformation();

            Coordinate dest = new Coordinate();
            AssertEqualPoint(pp0, atbTrans.Transform(p0, dest));
            AssertEqualPoint(pp1, atbTrans.Transform(p1, dest));
            AssertEqualPoint(pp2, atbTrans.Transform(p2, dest));
        }
コード例 #6
0
        static void RunSingular(double p0x, double p0y,
            double p1x, double p1y,
            double p2x, double p2y,
            double pp0x, double pp0y,
            double pp1x, double pp1y,
            double pp2x, double pp2y
            )
        {
            Coordinate p0 = new Coordinate(p0x, p0y);
            Coordinate p1 = new Coordinate(p1x, p1y);
            Coordinate p2 = new Coordinate(p2x, p2y);

            Coordinate pp0 = new Coordinate(pp0x, pp0y);
            Coordinate pp1 = new Coordinate(pp1x, pp1y);
            Coordinate pp2 = new Coordinate(pp2x, pp2y);

            AffineTransformationBuilder atb = new AffineTransformationBuilder(
                p0, p1, p2,
                pp0, pp1, pp2);
            AffineTransformation trans = atb.GetTransformation();
            Assert.IsNull(trans);
        }
コード例 #7
0
        public void TestInvertedItalicNTSConforming()
        {
            AffineTransformationBuilder atb = new AffineTransformationBuilder(
                new Coordinate(0, 0), new Coordinate(50, 0), new Coordinate(0, 100),
                new Coordinate(0, 0), new Coordinate(50, 0), new Coordinate(20, 100));

            IGeometry geom = _wktReader.Read(NTS);

            //Apply italic effect
            geom = atb.GetTransformation().Transform(geom);
            Console.WriteLine(geom.AsText());

            IGeometry constraint = ((IPolygon)geom).GetInteriorRingN(0);
            constraint = geom.Factory.CreatePolygon((ILinearRing)constraint, null);
            constraint = ((IPolygon)constraint.Buffer(-1)).Shell;
            Coordinate[] coordinates = constraint.Coordinates;
            coordinates[coordinates.Length - 1].X -= 1e-7;
            coordinates[coordinates.Length - 1].Y -= 1e-7;

            constraint = geom.Factory.CreateLineString(coordinates);
            Console.WriteLine(constraint.AsText());

            //Setup 
            ConformingDelaunayTriangulationBuilder dtb = new ConformingDelaunayTriangulationBuilder { Constraints = constraint };
            dtb.SetSites(geom);
            IMultiLineString result = dtb.GetEdges(geom.Factory);
            Console.WriteLine(result.AsText());


        }
コード例 #8
0
        public void TestInvertedItalicNTS()
        {
            AffineTransformationBuilder atb = new AffineTransformationBuilder(
                new Coordinate(0, 0),
                new Coordinate(50, 0),
                new Coordinate(0, 100),
                new Coordinate(0, 0),
                new Coordinate(50, 0),
                new Coordinate(20, 100));

            IGeometry geom = _wktReader.Read(NTS);

            //Apply italic effect
            geom = atb.GetTransformation().Transform(geom);
            Console.WriteLine(geom.AsText());

            //Setup 
            DelaunayTriangulationBuilder dtb = new DelaunayTriangulationBuilder();
            dtb.SetSites(geom);
            IMultiLineString result = dtb.GetEdges(geom.Factory);
            Console.WriteLine(result.AsText());
        }