Ejemplo n.º 1
0
        public void Solve(List<System.Drawing.PointF> pointList)
        {
            g.DrawLine(blackPen, 1, 2, 3, 4);
            g.DrawLine(blackPen, pointList[1], pointList[3]);

            pointList.Sort((a, b) =>
            {
                int result = a.X.CompareTo(b.X);
               return result;
            });
             c= new ConvexPoint[pointList.Count];
              int counter = 0;
            foreach (PointF element in pointList)
            {
            c[counter] = new ConvexPoint(element, -1);

               // System.Windows.Forms.MessageBox.Show(element.X + " " + element.Y);
                counter++;
            }

            //then call recursive method
            divideConvex(0,c.Length -1);
            string total = "";

            int nextX = 0;// c[0].clockWiseNeighbor;

            int currentX = 0;
            do
            {
                currentX = nextX;
                //System.Windows.Forms.MessageBox.Show(currentX + " => " +nextX);
                nextX = c[nextX].clockWiseNeighbor;
                g.DrawLine(testPen, c[currentX].p, c[nextX].p);

            } while (nextX != 0);

               /* for (int currentX = 0; currentX < c.Length; currentX ++)
            {

                total += c[currentX].clockWiseNeighbor + " ";

            } */
               // System.Windows.Forms.MessageBox.Show(total);
            //System.Windows.Forms.MessageBox.Show(total);
        }
Ejemplo n.º 2
0
        public void Solve(List<System.Drawing.PointF> pointList)
        {
            pointList.Sort((a, b) =>
            {
                int result = a.X.CompareTo(b.X);
               return result;
            });
             c= new ConvexPoint[pointList.Count];
              int counter = 0;
            foreach (PointF element in pointList)
            {
            c[counter] = new ConvexPoint(element, -1);

                counter++;
            }

            //then call recursive method
            divideConvex(0,c.Length -1);

            int nextX = 0;// c[0].clockWiseNeighbor;

            int currentX = 0;
            do
            {
                currentX = nextX;
                nextX = c[nextX].clockWiseNeighbor;
                g.DrawLine(testPen, c[currentX].p, c[nextX].p);

            } while (nextX != 0);
        }