Example #1
0
        /// <summary>
        /// Rect is entirely contained in the rectangle
        /// </summary>
        /// <param name="rect"></param>
        /// <returns></returns>
        public bool Contains(Rectangle2D rect)
        {
            if (rect.Size > Size)
            {
                return(false);                  // A bigger rectangle cannot entirely be contained in this one
            }
            //If we have a rectangle at the same reference point and it has smaller dimension
            if (UpperLeftPoint.Equals(rect.UpperLeftPoint) && rect.Width <= Width && rect.Height <= Height)
            {
                return(true);
            }
            //Only if all four edge points are within the rectangle - rect is in the rectangle entirely
            if (Contains(UpperLeftPoint) && Contains(new Point2D(X + Width, Y)) && Contains(new Point2D(X + Width, Y + Height)) && Contains(new Point2D(X, Y + Height)))
            {
                return(true);
            }

            return(false);
        }
Example #2
0
 public bool Equals(Line2D other)
 {
     return(StartPoint.Equals(other.StartPoint) && EndPoint.Equals(other.EndPoint));
 }