コード例 #1
0
        public void TestIsConvex_Robust()
        {
            IList <Point2d> points1 = AsList(new Point2d(0, 0), new Point2d(10, 0), new Point2d(10, 10), new Point2d(0, 10));
            IList <Point2d> points2 = AsList(new Point2d(0, 0), new Point2d(0, 10), new Point2d(10, 10), new Point2d(10, 0));

            Assert.AreEqual(true, PolygonUtils.IsConvex(points1, true));
            Assert.AreEqual(true, PolygonUtils.IsConvex(points2, true));

            IList <Point2d> points3 = AsList(new Point2d(0, 0), new Point2d(10, 0), new Point2d(10, 10), new Point2d(5, 10), new Point2d(5, 5), new Point2d(0, 5));
            IList <Point2d> points4 = AsList(new Point2d(0, 0), new Point2d(0, 10), new Point2d(10, 10), new Point2d(10, 5), new Point2d(5, 5), new Point2d(5, 0));

            Assert.AreEqual(false, PolygonUtils.IsConvex(points3, true));
            Assert.AreEqual(false, PolygonUtils.IsConvex(points4, true));

            IList <Point2d> points5 = DuplicatePoints(points1);
            IList <Point2d> points6 = DuplicatePoints(points2);

            Assert.AreEqual(true, PolygonUtils.IsConvex(points5, true));
            Assert.AreEqual(true, PolygonUtils.IsConvex(points6, true));

            IList <Point2d> points7 = DuplicatePoints(points3);
            IList <Point2d> points8 = DuplicatePoints(points4);

            Assert.AreEqual(false, PolygonUtils.IsConvex(points7, true));
            Assert.AreEqual(false, PolygonUtils.IsConvex(points8, true));
        }
コード例 #2
0
        public void TestSort()
        {
            IList <Point2d> points1 = AsList(new Point2d(0, 0), new Point2d(5, 0), new Point2d(10, 0),
                                             new Point2d(10, 10), new Point2d(15, 10), new Point2d(20, 10),
                                             new Point2d(20, 20), new Point2d(25, 20), new Point2d(30, 20));

            AssertEqualsListList(PolygonUtils.Sort2(points1),
                                 new[]
            {
                new[]
                {
                    new Point2d(0, 0), new Point2d(5, 0), new Point2d(10, 0),
                    new Point2d(10, 10), new Point2d(15, 10), new Point2d(20, 10),
                    new Point2d(20, 20), new Point2d(25, 20), new Point2d(30, 20)
                },
                new[]
                {
                    new Point2d(30, 20), new Point2d(0, 0)
                }
            });

            IList <Point2d> points2 = AsList(new Point2d(0, 0), new Point2d(5, 0), new Point2d(10, 0),
                                             new Point2d(10, 10), new Point2d(15, 10), new Point2d(20, 10),
                                             new Point2d(20, 20), new Point2d(25, 20), new Point2d(30, 20),
                                             new Point2d(30, 10), new Point2d(35, 10), new Point2d(40, 10),
                                             new Point2d(40, 0), new Point2d(45, 0), new Point2d(50, 0));

            AssertEqualsListList(PolygonUtils.Sort2(points2),
                                 new[]
            {
                new[]
                {
                    new Point2d(0, 0), new Point2d(5, 0), new Point2d(10, 0),
                    new Point2d(10, 10), new Point2d(15, 10), new Point2d(20, 10),
                    new Point2d(20, 20), new Point2d(25, 20), new Point2d(30, 20),
                    new Point2d(30, 10), new Point2d(35, 10), new Point2d(40, 10),
                    new Point2d(40, 0), new Point2d(45, 0), new Point2d(50, 0)
                },
                new[]
                {
                    new Point2d(50, 0), new Point2d(0, 0)
                }
            });

            IList <Point2d> points3 = AsList(new Point2d(20, 0), new Point2d(30, 10), new Point2d(20, 20), new Point2d(10, 20), new Point2d(0, 10), new Point2d(10, 0));

            AssertEqualsListList(PolygonUtils.Sort2(points3),
                                 new[]
            {
                new[]
                {
                    new Point2d(0, 10), new Point2d(10, 0), new Point2d(20, 0), new Point2d(30, 10)
                },
                new[]
                {
                    new Point2d(30, 10), new Point2d(20, 20), new Point2d(10, 20), new Point2d(0, 10)
                },
            });
        }
コード例 #3
0
        public void TestSignedArea2()
        {
            IList <Point2d> points1 = AsList(new Point2d(0, 0), new Point2d(10, 0), new Point2d(10, 10), new Point2d(0, 10));
            IList <Point2d> points2 = AsList(new Point2d(0, 0), new Point2d(0, 10), new Point2d(10, 10), new Point2d(10, 0));

            Assert.AreEqual(100d, PolygonUtils.SignedArea2(points1), MathUtils.EPSILON);
            Assert.AreEqual(-100d, PolygonUtils.SignedArea2(points2), MathUtils.EPSILON);
        }
コード例 #4
0
        public void TestTestOrientation()
        {
            IList <Point2d> points1 = AsList(new Point2d(0, 0), new Point2d(10, 0), new Point2d(10, 10), new Point2d(0, 10));
            IList <Point2d> points2 = AsList(new Point2d(0, 0), new Point2d(0, 10), new Point2d(10, 10), new Point2d(10, 0));

            Assert.AreEqual(Orientation.CCW, PolygonUtils.TestOrientation(points1, false));
            Assert.AreEqual(Orientation.CW, PolygonUtils.TestOrientation(points2, false));
        }
コード例 #5
0
ファイル: Polygon2d.cs プロジェクト: JohannesMP/Essence
        /**
         * This method tests if the point is on the edge.
         */
        public bool PointInEdge(Point2d p, double epsilon = MathUtils.EPSILON)
        {
            if (!this.BoundingBox.IsInterior(p, epsilon))
            {
                return(false);
            }

            return(PolygonUtils.PointInEdge(this.Vertices, p, this.robust, epsilon));
        }
コード例 #6
0
ファイル: Polygon2d.cs プロジェクト: JohannesMP/Essence
        /**
         * Winding number test for a point in a polygon.
         */
        public bool PointInPolyNonZero(Point2d p, bool extendedAlgorithm, double epsilon = MathUtils.EPSILON)
        {
            if (!this.BoundingBox.IsInterior(p, epsilon))
            {
                return(false);
            }

            return(PolygonUtils.PointInPolyNonZero(this.vertices, p, extendedAlgorithm, this.robust, epsilon) != Essence.Geometry.Geom2D.PointInPoly.Outside);
        }
コード例 #7
0
        public void TestOrientation_Robust()
        {
            IList <Point2d> points1 = AsList(new Point2d(0, 0), new Point2d(10, 0), new Point2d(10, 10), new Point2d(0, 10));
            IList <Point2d> points2 = AsList(new Point2d(0, 0), new Point2d(0, 10), new Point2d(10, 10), new Point2d(10, 0));

            Assert.AreEqual(Orientation.CCW, PolygonUtils.TestOrientation(points1, true));
            Assert.AreEqual(Orientation.CW, PolygonUtils.TestOrientation(points2, true));

            IList <Point2d> points3 = DuplicatePoints(points1);
            IList <Point2d> points4 = DuplicatePoints(points2);

            Assert.AreEqual(Orientation.CCW, PolygonUtils.TestOrientation(points3, true));
            Assert.AreEqual(Orientation.CW, PolygonUtils.TestOrientation(points4, true));
        }
コード例 #8
0
        public void TestNormalize()
        {
            IList <Point2d> points1 = new[]
            {
                new Point2d(10, 0),
                new Point2d(10, 10),
                new Point2d(0, 10),
                new Point2d(0, 0)
            };

            PolygonUtils.Normalize(points1);
            AssertEqualsList(points1, AsList(new Point2d(0, 0),
                                             new Point2d(10, 0),
                                             new Point2d(10, 10),
                                             new Point2d(0, 10)));

            IList <Point2d> points2 = AsList(new Point2d(10, 10),
                                             new Point2d(0, 10),
                                             new Point2d(0, 0),
                                             new Point2d(10, 0));

            PolygonUtils.Normalize(points2);
            AssertEqualsList(points2, AsList(new Point2d(0, 0),
                                             new Point2d(10, 0),
                                             new Point2d(10, 10),
                                             new Point2d(0, 10)));

            // Puntos repetidos.
            IList <Point2d> points3 = AsList(new Point2d(10, 0), new Point2d(10, 0),
                                             new Point2d(10, 10), new Point2d(10, 10),
                                             new Point2d(0, 10), new Point2d(0, 10),
                                             new Point2d(0, 0), new Point2d(0, 0));

            PolygonUtils.Normalize(points3);
            AssertEqualsList(points3, AsList(new Point2d(0, 0), new Point2d(0, 0),
                                             new Point2d(10, 0), new Point2d(10, 0),
                                             new Point2d(10, 10), new Point2d(10, 10),
                                             new Point2d(0, 10), new Point2d(0, 10)));

            IList <Point2d> points4 = AsList(new Point2d(10, 10), new Point2d(10, 10),
                                             new Point2d(0, 10), new Point2d(0, 10),
                                             new Point2d(0, 0), new Point2d(0, 0),
                                             new Point2d(10, 0), new Point2d(10, 0));

            PolygonUtils.Normalize(points4);
            AssertEqualsList(points4, AsList(new Point2d(0, 0), new Point2d(0, 0),
                                             new Point2d(10, 0), new Point2d(10, 0),
                                             new Point2d(10, 10), new Point2d(10, 10),
                                             new Point2d(0, 10), new Point2d(0, 10)));
        }
コード例 #9
0
        public void TestIsConvex()
        {
            IList <Point2d> points1 = AsList(new Point2d(0, 0), new Point2d(10, 0), new Point2d(10, 10), new Point2d(0, 10));
            IList <Point2d> points2 = AsList(new Point2d(0, 0), new Point2d(0, 10), new Point2d(10, 10), new Point2d(10, 0));

            Assert.AreEqual(true, PolygonUtils.IsConvex(points1, false));
            Assert.AreEqual(true, PolygonUtils.IsConvex(points2, false));

            IList <Point2d> points3 = AsList(new Point2d(0, 0), new Point2d(10, 0), new Point2d(10, 10), new Point2d(5, 10), new Point2d(5, 5), new Point2d(0, 5));
            IList <Point2d> points4 = AsList(new Point2d(0, 0), new Point2d(0, 10), new Point2d(10, 10), new Point2d(10, 5), new Point2d(5, 5), new Point2d(5, 0));

            Assert.AreEqual(false, PolygonUtils.IsConvex(points3, false));
            Assert.AreEqual(false, PolygonUtils.IsConvex(points4, false));
        }
コード例 #10
0
        public void TestPointInEdge()
        {
            IList <Point2d> points = AsList(new Point2d(10, 0),
                                            new Point2d(10, 10),
                                            new Point2d(0, 10),
                                            new Point2d(0, 0));

            Assert.IsTrue(PolygonUtils.PointInEdge(points, new Point2d(5, 0), true, MathUtils.EPSILON));
            Assert.IsTrue(PolygonUtils.PointInEdge(points, new Point2d(10, 5), true, MathUtils.EPSILON));
            Assert.IsTrue(PolygonUtils.PointInEdge(points, new Point2d(5, 10), true, MathUtils.EPSILON));
            Assert.IsTrue(PolygonUtils.PointInEdge(points, new Point2d(0, 5), true, MathUtils.EPSILON));

            Assert.IsFalse(PolygonUtils.PointInEdge(points, new Point2d(5, 5), true, MathUtils.EPSILON));
            Assert.IsFalse(PolygonUtils.PointInEdge(points, new Point2d(5, 15), true, MathUtils.EPSILON));
            Assert.IsFalse(PolygonUtils.PointInEdge(points, new Point2d(5, -5), true, MathUtils.EPSILON));

            // Using epsilon.
            Assert.IsFalse(PolygonUtils.PointInEdge(points, new Point2d(5, 5), true, 4.9));
            Assert.IsTrue(PolygonUtils.PointInEdge(points, new Point2d(5, 5), true, 5));
        }
コード例 #11
0
        public void TestPointInPolyEvenOdd_Default_Robust()
        {
            IList <Point2d> points1 = DuplicatePoints(AsList(new Point2d(0, 0), new Point2d(10, 10), new Point2d(0, 10)));
            IList <Point2d> points2 = DuplicatePoints(AsList(new Point2d(0, 0), new Point2d(10, 0), new Point2d(10, 10)));

            Assert.AreEqual(PointInPoly.Outside, PolygonUtils.PointInPolyEvenOdd(points1, new Point2d(5, 10), false, true, MathUtils.EPSILON));
            Assert.AreEqual(PointInPoly.Inside, PolygonUtils.PointInPolyEvenOdd(points1, new Point2d(0, 5), false, true, MathUtils.EPSILON));
            Assert.AreEqual(PointInPoly.Outside, PolygonUtils.PointInPolyEvenOdd(points1, new Point2d(5, 5), false, true, MathUtils.EPSILON));

            Assert.AreEqual(PointInPoly.Inside, PolygonUtils.PointInPolyEvenOdd(points2, new Point2d(5, 0), false, true, MathUtils.EPSILON));
            Assert.AreEqual(PointInPoly.Outside, PolygonUtils.PointInPolyEvenOdd(points2, new Point2d(10, 5), false, true, MathUtils.EPSILON));
            Assert.AreEqual(PointInPoly.Inside, PolygonUtils.PointInPolyEvenOdd(points2, new Point2d(5, 5), false, true, MathUtils.EPSILON));

            IList <Point2d> points3 = DuplicatePoints(AsList(new Point2d(0, 0), new Point2d(10, 0), new Point2d(10, 10), new Point2d(0, 10)));
            IList <Point2d> points4 = DuplicatePoints(AsList(new Point2d(0, 10), new Point2d(10, 10), new Point2d(10, 20), new Point2d(0, 20)));
            IList <Point2d> points5 = DuplicatePoints(AsList(new Point2d(10, 0), new Point2d(20, 0), new Point2d(20, 10), new Point2d(10, 10)));
            IList <Point2d> points6 = DuplicatePoints(AsList(new Point2d(10, 10), new Point2d(20, 10), new Point2d(20, 20), new Point2d(10, 20)));

            Assert.AreEqual(PointInPoly.Outside, PolygonUtils.PointInPolyEvenOdd(points3, new Point2d(5, 10), false, true, MathUtils.EPSILON));
            Assert.AreEqual(PointInPoly.Inside, PolygonUtils.PointInPolyEvenOdd(points4, new Point2d(5, 10), false, true, MathUtils.EPSILON));

            Assert.AreEqual(PointInPoly.Outside, PolygonUtils.PointInPolyEvenOdd(points5, new Point2d(15, 10), false, true, MathUtils.EPSILON));
            Assert.AreEqual(PointInPoly.Inside, PolygonUtils.PointInPolyEvenOdd(points6, new Point2d(15, 10), false, true, MathUtils.EPSILON));

            Assert.AreEqual(PointInPoly.Outside, PolygonUtils.PointInPolyEvenOdd(points3, new Point2d(10, 5), false, true, MathUtils.EPSILON));
            Assert.AreEqual(PointInPoly.Inside, PolygonUtils.PointInPolyEvenOdd(points5, new Point2d(10, 5), false, true, MathUtils.EPSILON));

            Assert.AreEqual(PointInPoly.Outside, PolygonUtils.PointInPolyEvenOdd(points4, new Point2d(10, 15), false, true, MathUtils.EPSILON));
            Assert.AreEqual(PointInPoly.Inside, PolygonUtils.PointInPolyEvenOdd(points6, new Point2d(10, 15), false, true, MathUtils.EPSILON));

            Assert.AreEqual(PointInPoly.Outside, PolygonUtils.PointInPolyEvenOdd(points3, new Point2d(10, 10), false, true, MathUtils.EPSILON));
            Assert.AreEqual(PointInPoly.Outside, PolygonUtils.PointInPolyEvenOdd(points5, new Point2d(10, 10), false, true, MathUtils.EPSILON));

            Assert.AreEqual(PointInPoly.Outside, PolygonUtils.PointInPolyEvenOdd(points4, new Point2d(10, 10), false, true, MathUtils.EPSILON));
            Assert.AreEqual(PointInPoly.Inside, PolygonUtils.PointInPolyEvenOdd(points6, new Point2d(10, 10), false, true, MathUtils.EPSILON));
        }
コード例 #12
0
        public void TestPointInPolyNonZero_Default()
        {
            IList <Point2d> points1 = AsList(new Point2d(0, 0), new Point2d(10, 10), new Point2d(0, 10));
            IList <Point2d> points2 = AsList(new Point2d(0, 0), new Point2d(10, 0), new Point2d(10, 10));

            Assert.AreEqual(PointInPoly.Outside, PolygonUtils.PointInPolyNonZero(points1, new Point2d(5, 10), false, true, MathUtils.EPSILON));
            Assert.AreEqual(PointInPoly.Inside, PolygonUtils.PointInPolyNonZero(points1, new Point2d(0, 5), false, true, MathUtils.EPSILON));
            Assert.AreEqual(PointInPoly.Outside, PolygonUtils.PointInPolyNonZero(points1, new Point2d(5, 5), false, true, MathUtils.EPSILON));

            Assert.AreEqual(PointInPoly.Inside, PolygonUtils.PointInPolyNonZero(points2, new Point2d(5, 0), false, true, MathUtils.EPSILON));
            Assert.AreEqual(PointInPoly.Outside, PolygonUtils.PointInPolyNonZero(points2, new Point2d(10, 5), false, true, MathUtils.EPSILON));
            Assert.AreEqual(PointInPoly.Inside, PolygonUtils.PointInPolyNonZero(points2, new Point2d(5, 5), false, true, MathUtils.EPSILON));

            IList <Point2d> points3 = AsList(new Point2d(0, 0), new Point2d(10, 0), new Point2d(10, 10), new Point2d(0, 10));
            IList <Point2d> points4 = AsList(new Point2d(0, 10), new Point2d(10, 10), new Point2d(10, 20), new Point2d(0, 20));
            IList <Point2d> points5 = AsList(new Point2d(10, 0), new Point2d(20, 0), new Point2d(20, 10), new Point2d(10, 10));
            IList <Point2d> points6 = AsList(new Point2d(10, 10), new Point2d(20, 10), new Point2d(20, 20), new Point2d(10, 20));

            Assert.AreEqual(PointInPoly.Outside, PolygonUtils.PointInPolyNonZero(points3, new Point2d(5, 10), false, true, MathUtils.EPSILON));
            Assert.AreEqual(PointInPoly.Inside, PolygonUtils.PointInPolyNonZero(points4, new Point2d(5, 10), false, true, MathUtils.EPSILON));

            Assert.AreEqual(PointInPoly.Outside, PolygonUtils.PointInPolyNonZero(points5, new Point2d(15, 10), false, true, MathUtils.EPSILON));
            Assert.AreEqual(PointInPoly.Inside, PolygonUtils.PointInPolyNonZero(points6, new Point2d(15, 10), false, true, MathUtils.EPSILON));

            Assert.AreEqual(PointInPoly.Outside, PolygonUtils.PointInPolyNonZero(points3, new Point2d(10, 5), false, true, MathUtils.EPSILON));
            Assert.AreEqual(PointInPoly.Inside, PolygonUtils.PointInPolyNonZero(points5, new Point2d(10, 5), false, true, MathUtils.EPSILON));

            Assert.AreEqual(PointInPoly.Outside, PolygonUtils.PointInPolyNonZero(points4, new Point2d(10, 15), false, true, MathUtils.EPSILON));
            Assert.AreEqual(PointInPoly.Inside, PolygonUtils.PointInPolyNonZero(points6, new Point2d(10, 15), false, true, MathUtils.EPSILON));

            Assert.AreEqual(PointInPoly.Outside, PolygonUtils.PointInPolyNonZero(points3, new Point2d(10, 10), false, true, MathUtils.EPSILON));
            Assert.AreEqual(PointInPoly.Outside, PolygonUtils.PointInPolyNonZero(points5, new Point2d(10, 10), false, true, MathUtils.EPSILON));

            Assert.AreEqual(PointInPoly.Outside, PolygonUtils.PointInPolyNonZero(points4, new Point2d(10, 10), false, true, MathUtils.EPSILON));
            Assert.AreEqual(PointInPoly.Inside, PolygonUtils.PointInPolyNonZero(points6, new Point2d(10, 10), false, true, MathUtils.EPSILON));
        }
コード例 #13
0
ファイル: Polygon2d.cs プロジェクト: JohannesMP/Essence
 /**
  * This method removes the suplicate points of this polygon.
  * <example><pre>
  * Polygon2D poly = new Polygon2D(new[]
  * {
  *     new Point2d(0, 0), new Point2d(0, 0), new Point2d(0, 0),
  *     new Point2d(10, 0), new Point2d(10, 0), new Point2d(10, 0),
  *     new Point2d(10, 10), new Point2d(10, 10), new Point2d(10, 10),
  *     new Point2d(0, 10), new Point2d(0, 10), new Point2d(0, 10),
  *     new Point2d(0, 0), new Point2d(0, 0), new Point2d(0, 0),
  * });
  * poly.RemoveDuplicatePoints();
  * Polygon2D poly = new Polygon2D(new[] { new Point2d(0, 0), new Point2d(10, 0), new Point2d(10, 10), new Point2d(0, 10), });
  * </pre></example>
  */
 public void RemoveDuplicatePoints(double epsilon = MathUtils.EPSILON)
 {
     PolygonUtils.RemoveDuplicatePoints(this.vertices, epsilon);
 }
コード例 #14
0
ファイル: Polygon2d.cs プロジェクト: JohannesMP/Essence
 /**
  * This method evaluates the orientation of this polygon.
  * <p>
  * {@link http://www.easywms.com/easywms/?q=en/node/3602}
  * {@link http://paulbourke.net/geometry/clockwise/}
  * {@link http://paulbourke.net/geometry/polygonmesh/}
  */
 public Orientation TestOrientation()
 {
     return(PolygonUtils.TestOrientation(this.vertices, this.robust));
 }
コード例 #15
0
ファイル: Polygon2d.cs プロジェクト: JohannesMP/Essence
 /**
  * This method evaluates the area of this polygon.
  */
 public double SignedArea()
 {
     return(PolygonUtils.SignedArea(this.vertices, this.robust));
 }
コード例 #16
0
ファイル: Polygon2d.cs プロジェクト: JohannesMP/Essence
 public Point2d Evaluate(double t)
 {
     return(PolygonUtils.Evaluate2D(this.vertices, true, t));
 }
コード例 #17
0
        public void TestPointInPolyNonZero_Extended_Robust()
        {
            Circle2 c    = new Circle2(new Point2d(0, 0), 5);
            double  tmin = c.TMin;
            double  tmax = c.TMax;
            double  tinc = (tmax - tmin) / 5;
            Point2d p0   = c.GetPosition(tmin);
            Point2d p1   = c.GetPosition(tmin + tinc);
            Point2d p2   = c.GetPosition(tmin + 2 * tinc);
            Point2d p3   = c.GetPosition(tmin + 3 * tinc);
            Point2d p4   = c.GetPosition(tmin + 4 * tinc);

            IList <Point2d> points = DuplicatePoints(AsList(p0, p2, p4, p1, p3));

            PointInPoly pip1 = PolygonUtils.PointInPolyNonZero(points, new Point2d(4, 0), true, true, MathUtils.EPSILON);

            Assert.AreEqual(PointInPoly.Inside, pip1);

            PointInPoly pip2 = PolygonUtils.PointInPolyNonZero(points, new Point2d(-2, 2), true, true, MathUtils.EPSILON);

            Assert.AreEqual(PointInPoly.Inside, pip2);

            PointInPoly pip3 = PolygonUtils.PointInPolyNonZero(points, new Point2d(-2, -2), true, true, MathUtils.EPSILON);

            Assert.AreEqual(PointInPoly.Inside, pip3);

            PointInPoly pip4 = PolygonUtils.PointInPolyNonZero(points, new Point2d(0, 0), true, true, MathUtils.EPSILON);

            Assert.AreEqual(PointInPoly.Inside, pip4);

            PointInPoly pip5 = PolygonUtils.PointInPolyNonZero(points, new Point2d(10, 0), true, true, MathUtils.EPSILON);

            Assert.AreEqual(PointInPoly.Outside, pip5);

            PointInPoly pip6 = PolygonUtils.PointInPolyNonZero(points, new Point2d(4, 3), true, true, MathUtils.EPSILON);

            Assert.AreEqual(PointInPoly.Outside, pip6);

            PointInPoly pip7 = PolygonUtils.PointInPolyNonZero(points, new Point2d(4, -3), true, true, MathUtils.EPSILON);

            Assert.AreEqual(PointInPoly.Outside, pip7);

            PointInPoly pip8 = PolygonUtils.PointInPolyNonZero(points, new Point2d(1, 1), true, true, MathUtils.EPSILON);

            Assert.AreEqual(PointInPoly.Inside, pip8);

            PointInPoly pip9 = PolygonUtils.PointInPolyNonZero(points, new Point2d(1, -1), true, true, MathUtils.EPSILON);

            Assert.AreEqual(PointInPoly.Inside, pip9);

            PointInPoly pip10 = PolygonUtils.PointInPolyNonZero(points, p4.Add(p1.Sub(p4).Unit.Mul(0.7)), true, true, MathUtils.EPSILON);

            Assert.AreEqual(PointInPoly.On, pip10);

            PointInPoly pip11 = PolygonUtils.PointInPolyNonZero(points, p4.Add(p1.Sub(p4).Unit.Mul(0.3)), true, true, MathUtils.EPSILON);

            Assert.AreEqual(PointInPoly.On, pip11);

            PointInPoly pip12 = PolygonUtils.PointInPolyNonZero(points, p1.Add(p3.Sub(p1).Unit.Mul(0.7)), true, true, MathUtils.EPSILON);

            Assert.AreEqual(PointInPoly.On, pip12);

            PointInPoly pip13 = PolygonUtils.PointInPolyNonZero(points, p1.Add(p3.Sub(p1).Unit.Mul(0.3)), true, true, MathUtils.EPSILON);

            Assert.AreEqual(PointInPoly.On, pip13);
        }
コード例 #18
0
ファイル: Polygon2d.cs プロジェクト: JohannesMP/Essence
 /**
  * This method ensures that polygon is CCW.
  */
 public void EnsureCCW()
 {
     PolygonUtils.EnsureCCW(this.vertices, this.robust);
 }