Пример #1
0
        public bool AddValidPoint(MyPoint p)
        {
            if (Points.Count < 2)
            {
                Points.Add(p);

                if (Points.Count == 2)
                {
                    double rise = Points[1].Y - Points[0].Y;
                    double run = Points[1].X - Points[0].X;

                    if (run != 0.0)
                    {
                        m = rise / run;
                        c = Points[0].Y - m * Points[0].X;
                    }
                    else
                    {
                        isVert = true;
                    }
                }
                return true;
            }
            else
            {
                return AddCollinearPoint(p);
            }
        }
Пример #2
0
 private bool AddCollinearPoint(MyPoint p)
 {
     if (this.PassesThroughPoint(p))
     {
         Points.Add(p);
         return true;
     }
     return false;
 }
Пример #3
0
 private bool PassesThroughPoint(MyPoint p)
 {
     if (isVert)
     {
         return p.X == Points[0].X;
     }
     else
     {
         return p.Y == m * p.X + c;
     }
 }
Пример #4
0
 public bool HasPoint(MyPoint p)
 {
     int nPoint = this.Points.Count;
     for (int i = 0; i < nPoint; i++)
     {
         if (this.Points[i].Equals(p))
         {
             return true;
         }
     }
     return false;
 }