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). 

Here is the dimensions of the element currently: 

```
Bounds at a 90 rotation: {
 height     30
 width      0
 x          25
 y          10
}

```

Here are the dimensions after the rotation is set to none: 

```
Bounds at rotation 0 {
 height     0
 width      30
 x          10
 y          25
}

```

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. 

Is there a simple formula to get the bounds at rotation 0 using the info I already have? 

*Update: The object is rotated around the center of the object.* 

**UPDATE:**  

What I need is something like the function below: 

```
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 }

```

I found a similar question [here](https://stackoverflow.com/questions/51462800/get-bounds-of-rotated-rectangle).

**UPDATE 2**  

Here is the code I have. It attempts to get the center point of the line and then the x, y, width, and height: 

```
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
    }
}

```

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. 

**UPDATE 3**

I need a function that returns the unrotated bounds of a rectangle. I have the bounds at a specific rotation already. 

```
function getUnrotatedRectangleBounds(rect, currentRotation) {
    // magic
    return unrotatedRectangleBounds;
}

```