public Rectangle(Point leftUp, Point rightUp, Point rightBottom, Point leftBottom) { if (ShapeUtils.IsRectangle(leftUp, rightUp, rightBottom, leftBottom, out var leftRightSide, out var upBottomSide)) { this.Coordinates = new[] { leftUp, rightUp, rightBottom, leftBottom }; this.leftRightSideLength = leftRightSide; this.upBottomSideLength = upBottomSide; }
private static bool IsSquare(Point leftUp, Point rightUp, Point rightBottom, Point leftBottom, out double sideLength) { var isRectangle = ShapeUtils.IsRectangle(leftUp, rightUp, rightBottom, leftBottom, out var leftRightSide, out var upBottomSide); if (isRectangle && Math.Abs(leftRightSide - upBottomSide) < ShapeUtils.Tolerance) { sideLength = leftRightSide; return(true); } sideLength = -1; return(false); }