Basically I ask this question for JavaScript: Calculate the coordinates of a rotated rectangle

In this case:
- iX = Width of the rotating (blue) HTML element
- iY = Height of the rotating (blue) HTML element
- bx = Width of bounding box (red)
- by = Limit border height (red)
- x = X coordinates of the bounding box (red)
- y = Y coordinates of bounding box (red)
- iAngle / t = Angle of rotation of the HTML element (blue, not shown, but used in the code below), FYI: In this example, this is 37 degrees (not so important for the example)
How to calculate X, Y, Height and Width of a bounding box (all red numbers) surrounding a rotated HTML element (given its width, height and rotation angle) using JavaScript? The key to this will be to get a rotating HTML element (blue square) of the X / Y source code to use as an offset somehow (this is not presented in the code below). CSS3 transform-origin may be required to determine the center point.
I have a partial solution, but calculating X / Y codes does not work properly ...
var boundingBox = function (iX, iY, iAngle) { var x, y, bx, by, t;
I feel that I'm so close, and still still ...
Thanks so much for any help you can provide!
HELP TO NEAATRICS ...
After the HTML element is rotated, the browser returns a "matrix transformation" or "rotation matrix", which looks like this: rotate(Xdeg) = matrix(cos(X), sin(X), -sin(X), cos(X), 0, 0); See this for more information .
I have a feeling that this will enlighten us on how to get the X, Y bounding box (red) based solely on the width, height and angle of the rotated element (blue).
New information
Humm ... interesting ...

Each browser seems to handle rotation differently in terms of X / Y! FF completely ignores it, IE and Opera draw a bounding box (but its properties are not displayed, that is: bx and by), and Chrome and Safari rotate the box! All correctly report X / Y, except FF. So ... the X / Y problem seems to exist only for FF! How very strange!
It should also be noted that $(document).ready(function () {...}); fires too early for the rotated X / Y to be recognized (which was part of my original problem!). I rotate the elements just before the X / Y request requests in $(document).ready(function () {...}); but they don't seem to be updated until some time after (!?).
When I get a little more time, I will raise jFiddle with an example, but I use a modified form of "jquery-css-transform.js", so I have a tiny bit during training before jFiddle ...
So ... what, FireFox? This is not cool man!
Plot Thickens ...
Well, FF12 seems to fix the problem with FF11 and now acts like IE and Opera. But now I'm back to square with X / Y, but at least I think I know why now ...
It seems that even if X / Y is correctly reported by browsers for the rotated object, "Xhost" X / Y still exists in the version without rotation. This seems to be the order of operations:
- Starting from a non-rotating element on X, Y 20.20
- Rotate the specified item, resulting in a report X, Y will be equal to 15.35
- Move the specified element through JavaScript / CSS in X, Y 10.10
- The browser logically disconnects the element to 20.20, moves to 10.10, then rotates again, resulting in X, Y 5.25
So ... I want the element to appear at 10.10 after rotation, but due to the fact that the element (apparently) is an inverted post-move, the resulting X, Y is different from the set X, Y.
It is my problem! So I really need a function to take the desired coordinates of the place (10.10) and work back from there to get the starting coordinates X, Y, which will lead to the rotation of the element in 10.10. At least I know what my problem is now, thanks to the internal workings of browsers, it seems that this is a 10 = 5 rotating element!