示例#1
0
        // Check if this box wholly contains another
        public bool Contains(Box box)
        {
            // Entry logging
      #if IS_LOGGING_METHODS
            Log.Write("Entering method");
      #endif

            // Initialize result as true
            bool result = true;

            // There is containment if and only if this box contains the other's top-
            // left and bottom-right corners
            if (!this.Contains(box.VertexAt(0)))
            {
                result = false; goto exit;
            }
            if (!this.Contains(box.VertexAt(2)))
            {
                result = false; goto exit;
            }

            // [*]  Exit trap
exit:

            // Exit logging
      #if IS_LOGGING_METHODS
            Log.Write("Exiting method");
      #endif

            // Return result
            return(result);
        }
示例#2
0
        // Check if this polygon intersects with a box
        public override bool IntersectsWith(Box box)
        {
            // Entry logging
      #if IS_LOGGING_METHODS
            Log.Write(String.Format("Entering method for {0}", this.Name));
      #endif

            // Initialize result as false
            bool result = false;

            // There is an intersection if and only if this polygon contains at least
            // one of the box's corners.
            if (this.Contains(box.VertexAt(0)))
            {
                result = true; goto exit;
            }
            else if (this.Contains(box.VertexAt(1)))
            {
                result = true; goto exit;
            }
            else if (this.Contains(box.VertexAt(2)))
            {
                result = true; goto exit;
            }
            else if (this.Contains(box.VertexAt(3)))
            {
                result = true; goto exit;
            }

            // [*]  Exit trap
exit:

            // Exit logging
      #if IS_LOGGING_METHODS
            Log.Write(String.Format("Exiting method for {0}", this.Name));
      #endif

            // Return result
            return(result);
        }
示例#3
0
        // Check if this circle wholly contains a box
        public bool Contains2(Box box)
        {
            // Entry logging
      #if IS_LOGGING_METHODS
            Log.Write(String.Format("Entering method for {0}", this.Name));
      #endif

            // Initialize result as true
            bool result = true;

            // There is containment if and only if this polygon contains all four of
            // the box's corners.
            if (!this.Contains(box.VertexAt(0)))
            {
                result = false; goto exit;
            }
            if (!this.Contains(box.VertexAt(1)))
            {
                result = false; goto exit;
            }
            if (!this.Contains(box.VertexAt(2)))
            {
                result = false; goto exit;
            }
            if (!this.Contains(box.VertexAt(3)))
            {
                result = false; goto exit;
            }

            // [*]  Exit trap
exit:

            // Exit logging
      #if IS_LOGGING_METHODS
            Log.Write(String.Format("Exiting method for {0}", this.Name));
      #endif

            // Return result
            return(result);
        }