예제 #1
0
        private static List <Form1.point> Sortare(List <Form1.point> EQ)
        {
            int schimbat = 1;

            do
            {
                schimbat = 0;
                for (int i = 0; i < EQ.Count - 1; i++)
                {
                    if (EQ[i].X > EQ[i + 1].X)
                    {
                        Form1.point aux = EQ[i];
                        EQ[i]     = EQ[i + 1];
                        EQ[i + 1] = aux;
                        schimbat  = 1;
                    }
                    else if (EQ[i].X == EQ[i + 1].X)
                    {
                        if (EQ[i].Y > EQ[i + 1].Y)
                        {
                            Form1.point aux = EQ[i];
                            EQ[i]     = EQ[i + 1];
                            EQ[i + 1] = aux;
                            schimbat  = 1;
                        }
                    }
                }
            }while (schimbat == 1);
            return(EQ.ToList());
        }
예제 #2
0
        private static int Orientation(Form1.point p1, Form1.point p2, Form1.point p)
        {
            // Determinant
            float Orin = (p2.X - p1.X) * (p.Y - p1.Y) - (p.X - p1.X) * (p2.Y - p1.Y);

            if (Orin > 0)
            {
                return(-1); //Orientarea este de la stanga la dreapta
            }
            if (Orin < 0)
            {
                return(1); //Orientarea este de la dreapta la stanga
            }
            return(0);     //Sunt colinieare
        }