private ConvexHull2Test()
        {
            _pointCloud1 = new Vertices(PointCount);

            for (int i = 0; i < PointCount; i++)
            {
                float x = Rand.RandomFloat(-10, 10);
                float y = Rand.RandomFloat(-10, 10);

                _pointCloud1.Add(new Vector2(x, y));
            }

            _pointCloud2 = new Vertices(_pointCloud1);
            _pointCloud3 = new Vertices(_pointCloud1);

            //Melkman DOES NOT work on point clouds. It only works on simple polygons.
            _pointCloud1.Translate(new Vector2(-20, 30));
            _melkman = Melkman.GetConvexHull(_pointCloud1);

            //Giftwrap works on point clouds
            _pointCloud2.Translate(new Vector2(20, 30));
            _giftWrap = GiftWrap.GetConvexHull(_pointCloud2);

            //Chain hull also works on point clouds
            _pointCloud3.Translate(new Vector2(20, 10));
            _chainHull = ChainHull.GetConvexHull(_pointCloud3);
        }
Example #2
0
        public void TestGetConvexHull()
        {
            Vertices?vertices = new Vertices();
            Vector2  point1   = new Vector2(0, 0);
            Vector2  point2   = new Vector2(1, 0);
            Vector2  point3   = new Vector2(0, 1);

            vertices.Add(point1);
            vertices.Add(point2);
            vertices.Add(point3);

            Vertices?convexHull = ChainHull.GetConvexHull(vertices);

            Assert.AreEqual(convexHull.Count, 3);
            Assert.IsTrue(convexHull[0] == vertices[0]);
            Assert.IsTrue(convexHull[1] == vertices[1]);
            Assert.IsTrue(convexHull[2] == vertices[2]);
        }