blog
Tag Archive for project at Jozef Chúťka's blog
November 16, 2010
axis collision FastCollisions Math2D project rectangle
4.000.000 Rectangle Collisions Per Second

However easy rectangle-collision-detection may look like, it is not. Well, before your rectangles got rotated, all you have to do is to measure points intersection on x and y axis, but once they got rotated you have to rethink the whole algorithm. After reading an article N Tutorial A – Collision Detection and Response, I got inspired and soon Math2D and FastCollisions were born.
What you have to do is to construct a new axis based on rectangle rotation. What first looked like x and y axis, now results into 2 axises per each rectangle (4 in total). First is the one that joins points 1 and 2, second that joins points 2 and 3 (see the final .swf to understand). Once you have 4 new axises you have to project points from other rectangle into the each axis and test intersection.