2d collision with rotated pictures

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
User avatar
pgimeno
Party member
Posts: 3655
Joined: Sun Oct 18, 2015 2:58 pm

Re: 2d collision with rotated pictures

Post by pgimeno »

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?
razerbladex43
Prole
Posts: 5
Joined: Mon Oct 26, 2020 12:08 am

Re: 2d collision with rotated pictures

Post by razerbladex43 »

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.

Image

rotated_boxes.love
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 ?
User avatar
siberian
Prole
Posts: 21
Joined: Sat Apr 06, 2019 1:42 pm

Re: 2d collision with rotated pictures

Post by siberian »

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 ?
Sorry, it's hard for me to explain it in English.
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
Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot], Bing [Bot], Google [Bot] and 2 guests