/// <summary>
        /// Heuristic method, based on the assumption that area of element stays the same, when we try to
        /// layout it with different available width (available width is between min-width and max-width).
        /// </summary>
        /// <param name="angle">rotation angle in radians</param>
        /// <param name="area">the constant area</param>
        /// <param name="elementMinMaxWidth">NOT rotated element min-max-width</param>
        /// <param name="availableWidth">the maximum width of area the element will occupy after rotation.</param>
        /// <returns>possible min-max-width of element after rotation</returns>
        public static iText.Layout.Minmaxwidth.RotationMinMaxWidth Calculate(double angle, double area, MinMaxWidth
                                                                             elementMinMaxWidth, double availableWidth)
        {
            RotationMinMaxWidth.WidthFunction          function       = new RotationMinMaxWidth.WidthFunction(angle, area);
            RotationMinMaxWidth.WidthFunction.Interval validArguments = function.GetValidOriginalWidths(availableWidth
                                                                                                        );
            if (validArguments == null)
            {
                return(null);
            }
            double xMin = Math.Max(elementMinMaxWidth.GetMinWidth(), validArguments.GetMin());
            double xMax = Math.Min(elementMinMaxWidth.GetMaxWidth(), validArguments.GetMax());

            if (xMax < xMin)
            {
                //Initially the null was returned in this case, but this result in old layout logic that looks worse in most cases.
                //The difference between min and max is not that big and not critical.
                double rotatedWidth  = function.GetRotatedWidth(xMin);
                double rotatedHeight = function.GetRotatedHeight(xMin);
                return(new iText.Layout.Minmaxwidth.RotationMinMaxWidth(rotatedWidth, rotatedWidth, xMin, xMin, rotatedHeight
                                                                        , rotatedHeight));
            }
            return(Calculate(function, xMin, xMax));
        }
 /// <summary>
 /// Heuristic method, based on the assumption that area of element stays the same, when we try to
 /// layout it with different available width (available width is between min-width and max-width).
 /// </summary>
 /// <param name="angle">rotation angle in radians</param>
 /// <param name="area">the constant area</param>
 /// <param name="elementMinMaxWidth">NOT rotated element min-max-width</param>
 /// <returns>possible min-max-width of element after rotation</returns>
 public static iText.Layout.Minmaxwidth.RotationMinMaxWidth Calculate(double angle, double area, MinMaxWidth
                                                                      elementMinMaxWidth)
 {
     RotationMinMaxWidth.WidthFunction function = new RotationMinMaxWidth.WidthFunction(angle, area);
     return(Calculate(function, elementMinMaxWidth.GetMinWidth(), elementMinMaxWidth.GetMaxWidth()));
 }