I'm trying to get the position of the actual rotated rectangle inside the bounding box.
The rectangle is rotated by 120deg
I'm trying to achieve the blue outline you can see here
I manage to get the rotation right using the matrix but I can't get the rest right.
Here is my code
let svg = document.querySelector('svg')
let overlay = document.querySelector('.overlay')
let rect = svg.children[0]
let bounds = rect.getBoundingClientRect()
let matrix = rect.getCTM()
overlay.style.top = bounds.top + 'px'
overlay.style.left = bounds.left + 'px'
overlay.style.width = bounds.width + 'px'
overlay.style.height = bounds.height + 'px'
overlay.style.transform = `matrix(${matrix.a},${matrix.b},${matrix.c},${matrix.d},0,0)`


Known data: bounding box width
W, heightH, rotation angleFiWanted: coordinates of rotated rectangle vertices.
Unknown source rectangle size:
w x hBounding box size for this dimension and rotation angle:
so we can solve linear equation system and get (note singularity for
Pi/4angle)Vertex coordinates:
Note that with given data we cannot differ between angles
Fiand90+Fibut this fact perhaps does not influence on solution (wandhwill exchange each other too)