示例#1
0
        public Square(Point goc, Point p2, bool hv = false)
        {
            A = goc;
            a = Math.Abs(p2.X - goc.X);
            b = Math.Abs(p2.Y - goc.Y);
            if (hv)
            {
                if (a > b)
                {
                    b = a;
                    if (p2.Y - goc.Y < 0)
                    {
                        C = new Point(p2.X, A.Y - a);
                    }
                    else
                    {
                        C = new Point(p2.X, A.Y + a);
                    }
                }
                else if (a == b)
                {
                    C = new Point(p2.X, p2.Y);
                }
                else
                {
                    a = b;
                    if (p2.X - goc.X < 0)
                    {
                        C = new Point(A.X - a, p2.Y);
                    }
                    else
                    {
                        C = new Point(A.X + a, p2.Y);
                    }
                }
                B = new Point(A.X, C.Y);
                //C = new Point(A.X + b, A.Y + a);
                D = new Point(C.X, A.Y);
            }
            else
            {
                C = new Point(p2.X, p2.Y);
                B = new Point(A.X, C.Y);

                D = new Point(C.X, A.Y);
            }
            ListCanh.Add(new Segment(A, B));
            ListCanh.Add(new Segment(B, C));
            ListCanh.Add(new Segment(C, D));
            ListCanh.Add(new Segment(D, A));
            foreach (Segment s in ListCanh)
            {
                List.AddRange(s.List);
            }
            Remove();
        }
示例#2
0
 public Square(Point goc, int canhNgan) /*Hình vuông*/
 {
     a = canhNgan;
     b = canhNgan;
     A = goc;
     B = new Point(A.X, A.Y + a);
     C = new Point(A.X + a, A.Y + a);
     D = new Point(A.X + a, A.Y);
     ListCanh.Add(new Segment(A, B));
     ListCanh.Add(new Segment(B, C));
     ListCanh.Add(new Segment(C, D));
     ListCanh.Add(new Segment(D, A));
     foreach (Segment s in ListCanh)
     {
         List.AddRange(s.List);
     }
     Remove();
 }
示例#3
0
 /* public void PhepTinhTien(int x, int y, int z = 0)
  * {
  *   List.Clear();
  *   ListCanh.Clear();
  *   A.PhepTinhTien(x, y, z);
  *   B.PhepTinhTien(x, y, z);
  *   C.PhepTinhTien(x, y, z);
  *   D.PhepTinhTien(x, y, z);
  *   ListCanh.Add(new Segment(A, B));
  *   ListCanh.Add(new Segment(B, C));
  *   ListCanh.Add(new Segment(C, D));
  *   ListCanh.Add(new Segment(D, A));
  *   foreach (Segment s in ListCanh)
  *   {
  *       List.AddRange(s.List);
  *   }
  * }*/
 public new void PhepTyLe(double x)
 {
     List.Clear();
     ListCanh.Clear();
     A.PhepTyLe(x, x);
     B.PhepTyLe(x, x);
     C.PhepTyLe(x, x);
     D.PhepTyLe(x, x);
     ListCanh.Add(new Segment(A, B));
     ListCanh.Add(new Segment(B, C));
     ListCanh.Add(new Segment(C, D));
     ListCanh.Add(new Segment(D, A));
     foreach (Segment s in ListCanh)
     {
         List.AddRange(s.List);
     }
     Remove();
 }