示例#1
0
        public void Test_Includeness()
        {
            var hash = new HashSet <(int, int)>();

            for (var numberOfTests = 0; numberOfTests < 100; ++numberOfTests)
            {
                var numberOfPoints = 20 + numberOfTests * 10;
                var arr            = new PointD2DAnnotated[numberOfPoints];

                hash.Clear();
                for (var i = 0; i < numberOfPoints;)
                {
                    var x = _random.Next(-1000, 1000);
                    var y = _random.Next(-1000, 1000);

                    if (!hash.Contains((x, y)))
                    {
                        hash.Add((x, y));
                        arr[i] = new PointD2DAnnotated(x, y, i);
                        ++i;
                    }
                }

                var convexHull = GrahamScan.GetConvexHull(arr);

                IncludenessTest(convexHull, arr);
            }
        }
示例#2
0
        private void CalculateConvexHullAsLineList(IEnumerable <PointD2DAnnotated> nodes)
        {
            ConvexHullPoints = GrahamScan.GetConvexHull(nodes);
            var hull_convex_edges = new List <LineD2DAnnotated>();

            for (var i = 0; i < ConvexHullPoints.Count - 1; i++)
            {
                hull_convex_edges.Add(new LineD2DAnnotated(ConvexHullPoints[i], ConvexHullPoints[i + 1]));
            }
            hull_convex_edges.Add(new LineD2DAnnotated(ConvexHullPoints[ConvexHullPoints.Count - 1], ConvexHullPoints[0]));

            _hull_convex_edges = hull_convex_edges;
        }