title: Get bounds of unrotated rotated rectangle
body: <p>I have a rectangle that has a rotation already applied to it. I want to get the the unrotated dimensions (the x, y, width, height). </p>
  
  <p>Here is the dimensions of the element currently: </p>
  
  <pre><code>Bounds at a 90 rotation: {
   height     30
   width      0
   x          25
   y          10
  }
  </code></pre>
  
  <p>Here are the dimensions after the rotation is set to none:  </p>
  
  <pre><code>Bounds at rotation 0 {
   height     0
   width      30
   x          10
   y          25
  }
  </code></pre>
  
  <p>In the past, I was able to set the rotation to 0 and then read the updated bounds . However, there is a bug in one of the functions I was using, so now I have to do it manually. </p>
  
  <p>Is there a simple formula to get the bounds at rotation 0 using the info I already have? </p>
  
  <p><em>Update: The object is rotated around the center of the object.</em> </p>
  
  <p><strong>UPDATE:</strong><br>
  What I need is something like the function below: </p>
  
  <pre><code>function getRectangleAtRotation(rect, rotation) {
      var rotatedRectangle = {}
      rotatedRectangle.x = Math.rotation(rect.x * rotation);
      rotatedRectangle.y = Math.rotation(rect.y * rotation);
      rotatedRectangle.width = Math.rotation(rect.width * rotation);
      rotatedRectangle.height = Math.rotation(rect.height * rotation);
      return rotatedRectangle;
  }
  
  var rectangle = {x: 25, y: 10, height: 30, width: 0 };
  var rect2 = getRectangleAtRotation(rect, -90); // {x:10, y:25, height:0, width:30 }
  </code></pre>
  
  <p>I found a similar question <a href="https://stackoverflow.com/questions/51462800/get-bounds-of-rotated-rectangle">here</a>.</p>
  
  <p><strong>UPDATE 2</strong><br>
  Here is the code I have. It attempts to get the center point of the line and then the x, y, width, and height: </p>
  
  <pre><code>var centerPoint = getCenterPoint(line);
  var lineBounds = {};
  var halfSize;
  
  halfSize = Math.max(Math.abs(line.end.x-line.start.x)/2, Math.abs(line.end.y-line.start.y)/2);
  lineBounds.x = centerPoint.x-halfSize;
  lineBounds.y = centerPoint.y;
  lineBounds.width = line.end.x;
  lineBounds.height = line.end.y;
  
  function getCenterPoint(node) {
      return {
          x: node.boundsInParent.x + node.boundsInParent.width/2,
          y: node.boundsInParent.y + node.boundsInParent.height/2
      }
  }
  </code></pre>
  
  <p>I know the example I have uses a right angle and that you can swap the x and y with that but the rotation can be any amount. </p>
  
  <p><strong>UPDATE 3</strong></p>
  
  <p>I need a function that returns the unrotated bounds of a rectangle. I have the bounds at a specific rotation already. </p>
  
  <pre><code>function getUnrotatedRectangleBounds(rect, currentRotation) {
      // magic
      return unrotatedRectangleBounds;
  }
  </code></pre>