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 3x3 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)?