code: def rotated_rect_with_max_area(
      w: int, h: int, angle: float
  ) -> Tuple[float, float]:
      """
      Computes the width and height of the largest possible axis-aligned
      rectangle (maximal area) within the rotated rectangle
  
      source:
      https://stackoverflow.com/questions/16702966/rotate-image-and-crop-out-black-borders # noqa: B950
      """
      width_is_longer = w >= h
      side_long, side_short = (w, h) if width_is_longer else (h, w)
  
      sin_a = abs(math.sin(math.radians(angle)))
      cos_a = abs(math.cos(math.radians(angle)))
      if (
          side_short <= 2.0 * sin_a * cos_a * side_long
          or abs(sin_a - cos_a) < 1e-10
      ):
          x = 0.5 * side_short
          wr, hr = (
              (x / sin_a, x / cos_a)
              if width_is_longer
              else (x / cos_a, x / sin_a)
          )
      else:
          cos_2a = cos_a * cos_a - sin_a * sin_a
          wr = (w * cos_a - h * sin_a) / cos_2a
          hr = (h * cos_a - w * sin_a) / cos_2a
      return wr, hr
  
file_path: AugLy/augly/image/utils/utils.py
imports: import functools
  import json
  import math
  import os
  from typing import List, Optional, Tuple, Union
  import numpy
  from augly import utils
  from PIL import Image
label_desc: Use image node_id 5 for calling a global function with example usage: rotated_rect_with_max_area(w, h, angle) and returns: wr,  hr