2

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: Two quadrangles http://files.myopera.com/antonijn/albums/12693002/TwoQuadrangles.png

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!

Any suggestions?

Nicol Bolas
  • 449,505
  • 63
  • 781
  • 982
antonijn
  • 5,702
  • 2
  • 26
  • 33

1 Answers1

0

I ended up using the SAT method, as suggested by Nickon, thanks a bunch mate!

antonijn
  • 5,702
  • 2
  • 26
  • 33