I'm writing a collision algorithm based on the Separating Axis Theorem that works like so for each side:
- Gets the separating axis of the side
- Measures the object's width on that axis and places the width on the axis.
- Measures/places width for object that is being collision-tested.
- Draws two (unrotated) rectangles, herein referred to as axial rectangles, on the widths, using them as diagonals.
- Runs the SAT on the two axial rectangles, which are x/y aligned unlike the objects being tested,. If they overlap, the tested objects overlap on the given axis. If they overlap on 2 or more axes, they intersect.
My questions are these:
1. Is this the most efficient way to do it? Can you test the overlap of two line segments that doesn't correspond to the system's coordinates? IE, not both on an X or Y axis?
2. Given the two shapes I'm drawing, how do I move both axial rectangles so that their diagonals (the widths) are actually collinear on the axis? I can't figure out a way to do that.