[Math] Area of overlapping squares

areageometryrectanglesrotations

...

I'm working on a programming project and got to the point where I need to find how much is the blue square overlapping each of the other 9 squares. The squares' sides(including the blue one's) are 1-length. The blue square is tilted by the alpha angle.
I've thought of some trivial approaches to the problem, but they are severely inefficient, and due to the fact that I have to run this test around 784 X 42000 times, an analytic solution would be best. Also, I also thought of checking each of the 2 triangles in the blue square to the triangles in the other squares, but that means 36 checks, which is quite slow.

I would like to get something like a 3×3 matrix with the areas of the overlapping regions (some of the values in the matrix may be 0).

Assuming we know the coordinates of A, B, C, D and the angle alpha (we would only need to know two of them actually), is there a more efficient approach to finding the area of the overlapping parts (and filling the matrix)?

Best Answer

As I saw I probably won't be getting an answer I took a more naive path. I sampled the blue square by 100 points (10x10) and just approximated the overlapping areas using the number of points contained by the other squares. It proved to be precise enough, and yielded pretty good results for my task.

I know it's not a real mathematical solution to the problem, but maybe it will help other people facing the same task.

Related Question