コード例 #1
0
        public static bool AreClose(Rectangle2D rect1, Rectangle2D rect2, double epsilon = DoubleEpsilon)
        {
            // If they're both empty, don't bother with the double logic.
            if (RectangleIsEmptyTests.IsRectangleEmpty(rect1.Width, rect1.Height))
            {
                return(RectangleIsEmptyTests.IsRectangleEmpty(rect2.Width, rect2.Height));
            }

            // At this point, rect1 isn't empty, so the first thing we can test is
            // rect2.IsEmpty, followed by property-wise compares.
            return((!RectangleIsEmptyTests.IsRectangleEmpty(rect2.Width, rect2.Height)) &&
                   AreCloseTests.AreClose(rect1.X, rect2.X, epsilon) &&
                   AreCloseTests.AreClose(rect1.Y, rect2.Y, epsilon) &&
                   AreCloseTests.AreClose(rect1.Height, rect2.Height, epsilon) &&
                   AreCloseTests.AreClose(rect1.Width, rect2.Width, epsilon));
        }
コード例 #2
0
 public static bool AreClose1(double x1, double y1, double x2, double y2, double epsilon = DoubleEpsilon)
 {
     return(AreCloseTests.AreClose(x1, x2, epsilon) &&
            AreCloseTests.AreClose(y1, y2, epsilon));
 }