There are two moving rectangles A and B in a 2D space.
- Initially the centers of the rectangles are (x_A, y_A) and (x_B, y_B).
- The widths and lengths are w_A, h_A, w_B, h_B.
- The velocities are (v_Ax, v_Ay), (v_Bx, v_By).
- The angles between the longer edges and the velocities are θ_A, θ_B. In other words, θ is the angle that the rectangle needs to rotate counterclockwise so that the longer edges are parallel to the velocity. (see the picture below).
The questions are:
check if the two rectangles would collide while moving;
if there is no collision, what is the minimum distance (between any two points of the rectangles).
Similar questions are: How to check intersection between 2 rotated rectangles? and Collision detection between two rectangles in java However, they consider only static rectangles.
Thanks!