[Math] Find out whether two rectangles are intersecting in 3D space

3d

I've got two rectangles in 3D space, each given by the coordinates of their 4 corners. They are not axis aligned, meaning their edges are not necessarily parallel/perpendicular to the world axes. Each rectangle can have any orientation.

Is there an easy way to know whether or not the two rectangles are intersecting?

Best Answer

Find the intersection points of both rectangles in the plane of the other. You achieve that by plugging the coordinates of the vertices in the implicit equation of the plane and detecting a change of sign.

If you obtain four intersection points, which define two line segments, it suffices to test if these segments overlap (and where if you need the endpoints). Project the points on the direction of the common line (cross-product of the normal vectors), and you will get scalar values corresponding to abscissas along that line.

Checking for overlap in 1D is trivial.