public static Rect2D Union(this Rect2D rect, Route route) { if (route == null) { throw new ArgumentNullException(nameof(route)); } var result = rect; foreach (var point in route) { result = result.Union(point); } return(result); }
public static Rect2D Intersect(Rect2D rect1, Rect2D rect2) { if (rect1.IsUndefined() || rect2.IsUndefined()) { return(Undefined); } var left = Math.Max(rect1.Left, rect2.Left); var top = Math.Max(rect1.Top, rect2.Top); var right = Math.Min(rect1.Right, rect2.Right); var bottom = Math.Min(rect1.Bottom, rect2.Bottom); return(left >= right || top >= bottom ? Undefined : new Rect2D(new Point2D(left, top), new Point2D(right, bottom))); }
public static Rect2D Union(Rect2D rect1, Rect2D rect2) { if (rect1.IsUndefined()) { return(rect2); } if (rect2.IsUndefined()) { return(rect1); } var left = Math.Min(rect1.Left, rect2.Left); var top = Math.Min(rect1.Top, rect2.Top); var right = Math.Max(rect1.Right, rect2.Right); var bottom = Math.Max(rect1.Bottom, rect2.Bottom); return(new Rect2D(new Point2D(left, top), new Point2D(right, bottom))); }
public bool Equals(Rect2D other) { return(TopLeft.Equals(other.TopLeft) && Size.Equals(other.Size)); }
public bool Equals(Rect2D other) { return(Size.Equals(other.Size) && Center.Equals(other.Center)); }
public static bool IsUndefined(this Rect2D rect) { return(double.IsNaN(rect.Left) || double.IsNaN(rect.Top) || double.IsNaN(rect.Width) || double.IsNaN(rect.Height)); }
public static Rect2D Intersect(this Rect2D rect1, Rect2D rect2) { return(Rect2D.Intersect(rect1, rect2)); }
public static Rect2D Union(this Rect2D rect, Point2D point) { return(Union(rect, new Rect2D(point, point))); }
public static Rect2D Union(this Rect2D rect1, Rect2D rect2) { return(Rect2D.Union(rect1, rect2)); }
public static bool IsDefined(this Rect2D rect) => !rect.IsUndefined();