Beispiel #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));
        }
Beispiel #2
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));
        }