示例#1
0
        /// <summary>
        /// Determines if this region is equal to the specified region using the specified precision.
        /// </summary>
        /// <param name="region">The region.</param>
        /// <param name="precision">The precision.</param>
        /// <returns></returns>
        public bool Equals(Region2D region, int precision)
        {
            if ((object)region == null)
            {
                return(false);
            }

            // Return true if the fields match:
            return(Location.Equals(region.Location, precision) && Size.Equals(region.Size, precision));
        }
示例#2
0
        /// <summary>
        /// Determines if this region intersects the specified region.
        /// </summary>
        /// <param name="region">The other region.</param>
        /// <returns></returns>
        public bool Intersects(Region2D region)
        {
            bool xOverlap = valueInRange(this.X, region.X, region.X + region.Width) ||
                            valueInRange(region.X, this.X, this.X + this.Width);

            bool yOverlap = valueInRange(this.Y, region.Y, region.Y + region.Height) ||
                            valueInRange(region.Y, this.Y, this.Y + this.Height);

            return(xOverlap && yOverlap);
        }
示例#3
0
        /// <summary>
        /// Determines whether the specified <see cref="T:System.Object" /> is equal to the current <see cref="T:System.Object" />.
        /// </summary>
        /// <param name="obj">The object to compare with the current object.</param>
        /// <returns>
        /// true if the specified <see cref="T:System.Object" /> is equal to the current <see cref="T:System.Object" />; otherwise, false.
        /// </returns>
        public override bool Equals(Object obj)
        {
            Region2D region = obj as Region2D;

            if ((object)region == null)
            {
                return(false);
            }

            return(Equals(region));
        }
示例#4
0
 /// <summary>
 /// Divides the specified region by the specified constant.
 /// </summary>
 /// <param name="region">The region.</param>
 /// <param name="constant">The constant.</param>
 public static Region2D Divide(Region2D region, double constant)
 {
     return(new Region2D(region.X / constant, region.Y / constant, region.Width / constant, region.Height / constant));
 }
示例#5
0
 /// <summary>
 /// Multiplies the specified region by the specified constant.
 /// </summary>
 /// <param name="region">The region.</param>
 /// <param name="constant">The constant.</param>
 public static Region2D Multiply(Region2D region, double constant)
 {
     return(new Region2D(region.X * constant, region.Y * constant, region.Width * constant, region.Height * constant));
 }