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?
2d collision with rotated pictures
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
-
- Prole
- Posts: 5
- Joined: Mon Oct 26, 2020 12:08 am
Re: 2d collision with rotated pictures
that's exactly what i need. But this is so complicated. tell me if i'm wrong : so the main idea is to check if a dot from one of these polygon is inside the other one, is'nt it ?siberian wrote: ↑Wed Oct 28, 2020 7:55 am May be will be usefull.
The main idea is to get the sum of the 2 shapes (hull). If the center of an object is inside a hull, the objects are intersecting.
In motion, check the intersection of the hull with a segment from the center of the moved object to its destination point.
rotated_boxes.love
Re: 2d collision with rotated pictures
Sorry, it's hard for me to explain it in English.razerbladex43 wrote: ↑Wed Oct 28, 2020 6:25 pm so the main idea is to check if a dot from one of these polygon is inside the other one, is'nt it ?
If you want to check if the two boxes intersect, then you need to check if the center of the first object is included in the polygon obtained as a Minkowski addition of these two shapes, located in the center of the second box. Minkowski sum is a yellow polygon on the screenshot.
If you need to check the collision of a moving object, you need to check the intersection of the yellow polygon with a segment from the center of the first object to the destination point.
Maybe a post on this link will explain better
https://gamedev.stackexchange.com/quest ... ects/55991
Who is online
Users browsing this forum: No registered users and 5 guests