Rectangle Rotation Collision

What is the most efficient way to find out if a single rectangle collides with an axis aligned with one rotating rectangle? Each class has a position vector and a size vector, and the rotated class has an angle value.

+3
source share
2 answers

You want to use the separation axis theorem (SAT). It is usually used in 3d, but it drops quickly enough to 2d. Since you have a special case, the only axis you need to consider is the 4 main axes of your rectangles:

[1,0]
[0,1]
[sin (theta), cos (theta)]
[-cos (theta), sin (theta)]

, . min max , , . - , , ( ). 4 , .

SO : Python

http://en.wikipedia.org/wiki/Separating_axis_theorem

+5

- , , .

, "", , . , . , .

"" , ; , , ( ).

, , , . , , .

+3
source

All Articles