Re: 2d collision with rotated pictures
Posted: Wed Oct 28, 2020 11:00 am
SAT is simple. If two convex objects do not intersect, it means there is a line ("axis") so that one of them is entirely on one side of the line, and the other is entirely on the other side. This axis (line) is said to separate the objects (hence the name of the theorem). Furthermore, if the objects are polygons, one of the edges of one of the polygons must be able to work as a separating axis.
To detect a collision using SAT, you just need to check, for each of the edges of each of the polygons, if all vertices of the other polygon are on the opposite side of the edge line, with respect to current polygon's vertices.
Or you can follow FloatingBanana's advice and use HC, which already does it for you and can help you get it up and running faster. You said you were in a hurry, right?
To detect a collision using SAT, you just need to check, for each of the edges of each of the polygons, if all vertices of the other polygon are on the opposite side of the edge line, with respect to current polygon's vertices.
Or you can follow FloatingBanana's advice and use HC, which already does it for you and can help you get it up and running faster. You said you were in a hurry, right?