Esempio n. 1
0
        private Poligon UpdateHull(Poligon hull, List <PointF> sortedPoints, int index)
        {
            int hullSize    = hull.GetNumberOfPoints();
            int orientation = OrientationTest(hull.GetPointAt(hullSize - 2), hull.GetPointAt(hullSize - 1), sortedPoints[index]);

            if (orientation == 2)
            {
                hull.AddPoint(sortedPoints[index]);
                Console.Write(sortedPoints[index].X + " " + sortedPoints[index].Y);
            }

            else if (orientation == 1)
            {
                hull.RemovePoint();
                hull.AddPoint(sortedPoints[index]);
                Console.Write(sortedPoints[index].X + " " + sortedPoints[index].Y);
            }

            else
            {
                PointF furthestPoint = HighestY(hull.GetPointAt(hullSize - 1), sortedPoints[index]);
                hull.RemovePoint();
                hull.AddPoint(furthestPoint);
                Console.Write(furthestPoint.X + " " + furthestPoint.Y);
            }

            return(hull);
        }
Esempio n. 2
0
        private void generateBtn_Click(object sender, EventArgs e)
        {
            grafic.Series["Acoperire convexa"].Points.Clear();

            acoperireConvexa = poligon.GenerateHull();
            // MessageBox.Show(acoperireConvexa.GetNumberOfPoints().ToString());
            for (int i = 0; i < acoperireConvexa.GetNumberOfPoints(); ++i)
            {
                double x = acoperireConvexa.GetPointAt(i).X;

                double y = acoperireConvexa.GetPointAt(i).Y;


                grafic.Series["Acoperire convexa"].Points.AddXY(x, y);
                grafic.Series["Puncte acoperire convexa"].Points.AddXY(x, y);
            }

            grafic.Series["Acoperire convexa"].Points.AddXY(acoperireConvexa.GetPointAt(0).X, acoperireConvexa.GetPointAt(0).Y);
        }