Пример #1
0
        public void getConvexHullTest()
        {


            PointF[] polygons = new PointF[] { new Point(0,0), new Point(0, 2), new Point(2, 2),
                                                new Point(2,0), new Point(1,1) };
            List<PointF> convexHull = Utils.getConvexHull(polygons.ToList());
            List<PointF> trueConvexHull = new PointF[] {new Point(0,0), new Point(0, 2), new Point(2, 2),
                                                new Point(2,0)}.ToList();
            Assert.AreEqual(trueConvexHull.Except(convexHull).Count(), 0);
            Assert.AreEqual(convexHull.Except(trueConvexHull).Count(), 0);

            polygons = new PointF[] { new Point(0,0), new Point(0, 4), new Point(1, 3), new Point(2, 2), new Point(4, 5),
                                                new Point(4,1), new Point(5,0) };
            convexHull = Utils.getConvexHull(polygons.ToList());
            trueConvexHull = new PointF[] {new Point(0,0), new Point(0, 4), new Point(4, 5),
                                                new Point(5,0) }.ToList();

            Assert.AreEqual(trueConvexHull.Except(convexHull).Count(), 0);
            Assert.AreEqual(convexHull.Except(trueConvexHull).Count(), 0);
        }