I have a rectangle and a matrix of rectangles.
I want to check which rectangle in the matrix collides the most with the single rectangle and change his position to fit the matrix's rectangle.
This is how my rectangles are represents
{
x: X,
y: Y,
width: WIDTH,
height: height
}
The matrix is just a simple array (9) of rectangles. As you can see in the following picture the rectangle can fit in any of the 9 squared positions, the problem is that I don't know how to calculate with which of the squares the rectangles collides the most.
Thank you very much. I'll appriciate any answer.
