static void FindFarthestPoint(List <PointF> points, PointF A, PointF B)
        {
            float  distance   = 0;
            PointF upperPoint = new PointF();

            foreach (var point in points)
            {
                float lineDist = upperDistance(A, B, point);
                if (lineDist > distance)
                {
                    distance   = lineDist;
                    upperPoint = point;
                }
            }

            if (distance == 0)
            {
                resultHull.Add(A);
                resultHull.Add(B);
                QuickHullGraphics.DrawLines(resultHull);
                return;
            }

            FindFarthestPoint(points, A, upperPoint);
            FindFarthestPoint(points, upperPoint, B);
        }
        public void QuickHullAlgorithm(List <PointF> points)
        {
            QuickHullGraphics.Clear();
            QuickHullGraphics.DrawPoints(points);

            List <PointF> resultHull = QuickHull.ConvexHull(points);

            QuickHullGraphics.FinishLines(resultHull);
        }
Esempio n. 3
0
        private void MergeBtn_Click(object sender, EventArgs e)
        {
            List <PointF> points = RandomPoints(30);

            points = points.OrderBy(point => point.X).ToList();
            QuickHullGraphics.DrawPoints(points);
            points = DivideAndConquer.ConvexHull(points);
            QuickHullGraphics.Clear();
            QuickHullGraphics.FinishLines(points);
            QuickHullGraphics.DrawPoints(points);
        }
Esempio n. 4
0
 private void DivideAndConquerForm_Load(object sender, EventArgs e)
 {
     Gfx = Canvas.CreateGraphics();
     Gfx.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality;
     QuickHullGraphics.Initialize(Gfx);
 }
 private void QuickHullForm_Load(object sender, EventArgs e)
 {
     gfx = Canvas.CreateGraphics();
     gfx.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality;
     QuickHullGraphics.Initialize(gfx);
 }