Imagine I have $2$ axis aligned rectangles both moving along a vector. They can't overlap with each other so on collision, they will be stopped. Both shapes goes at the same speed relative to their vector meaning that $A$ takes the same time to reach the end of his vector than $B$ does, even if his vector is longer.
In that case for rectangle $A$, the normal of the side in contact with rectangle $B$ is $(1, 0)$. (And for $B$ it's $(-1, 0)$)
If I have the coordinates for both rectangles, their size and their movement vector, how can I get on which side rectangle $A$ will touch rectangle $B$?
I need a solution that works even if they are not touching and even if they are already overlapping. In those 2 cases, the vector can be extended to infinity or to negative infinity (in the other direction) but the length of the vector still indicates the relative movement of the shapes.
I have a physics engine with a continuous collision detection that works for a single side of a rectangle. (In other words, it checks if 2 segments will collide with their vector). It already works and I do not want to touch this algorithm. For the AABB vs AABB continuous collision detection, I do 4 detections for all of their sides which is stupid and inefficient. What I would like is to be able to know on which side perform the collision detection. Is it possible to get that with a simple formula ?