I have a large window in which there are n small windows. Task to place small windows so that between them there was no intersection, or say that it’s impossible to do.
All windows are rectangular and have the coordinates of all vertices.
I understand how easy it is to determine whether cross one of the rectangles with the others. It’s enough to look at include whether the coordinates of the vertices in any other rectangle.
But here’s how to find a free area where you could move this rectangle?
In my case, small windows appear in the big one. And the problem looks like.

This looks somewhat like a Rectangle Packing problem.
There are examples and implementations out there that can help.
The thing that differs is that you’re dealing with an UI, not textures or some other problem. You can go for the above mentioned solutions, but I imagine you will need some sort of transition animation so the user sees/understands where all his/her window will end up.
It depends how this feature works I presume. Is the user allowed to intersect windows in the first place ?
I imagine all rectangles will need to fit into a larget one (the display)
I’ve been playing with different sized rectangles of paper on my desk and here is something that comes to mind:
1st determine if all you’ve got enough space: split the left over space into rectangles and add the rectangle areas then check if the space areas are larger or equal to the intersection areas. If so continue.
the remaining directions (e.g. left,top-left,top,etc.)
then check again if the extra space is sufficient.
Here’s what I mean by splitting the remaining space into boxes to find the area:

I would suggest first checking the rectangle packing solutions I’ve linked to, as they use the available space optimally and it actually works, not something I came with by playing with paper 🙂
I haven’t coded/tested my solution yet.
HTH