How to calculate the new $X$ and $Y $ position of an object after changing its size?

66 Views Asked by At

I have some objects that will be positioned in certain $X$ and $Y$ coordinates and that will start with a size of $40\times60$ at an angle of $15^\circ$.

I need to change the size of these objects to $200\times200$ for example, with this the $X$ and $Y$ coordinates will change, it is important that the objects do not collide and respect the angle, and if there is a Gap this must be respected as well.

I included some examples of how the objects will be initially, and a gif showing that after changing the size they occupy a new $X$ and $Y$ position and do not collide. I made these examples using Figma software to facilitate the explanation.

I need to calculate the new $X$ and $Y$ coordinates of the objects dynamically, respecting the criteria above.

Pictures examples: enter image description here enter image description here