/// <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)); }
/// <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); }
/// <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)); }
/// <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)); }
/// <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)); }