Quadrangle intersection algorithm
I'm currently writing a game (2D with OpenTK) in which there is a lot of rotation, and with it comes that I sometimes need to get the intersection between these lines/shapes:
I know the rotation (in degrees) of both of them, and therefore I know the position of all the vertices in both shapes.
The algorithm needs to give me a bool on whether they intersect, or better yet, the coordinates of the intersections.
I have written my own algorithm, which scrolls through the sides of the first box, gets the formula for each side and compares them to the formulas of the lines of the second box. Now, this doesn't work when the lines are upright (slope of float.Infinity or float.NegativeInfinity), is a pain to debug and is far from fast, so I need a better one!
I ended up using the SAT method, as suggested by Nickon, thanks a bunch mate!