1
\$\begingroup\$

I would like to know how to implement this collision detection function, but I'm not even sure what it's called.

The input shapes are 2D convex polygons, with an optional "rounding radius": imagine putting a circle on each vertex of the polygon, and filling in the area between them.

I already have a function that uses SAT to tell if they intersect (and return a minimum correction vector), but I also need a function that takes two of these shapes, A and B, and a unit direction vector. It should tell whether A will ever touch B if it moves along the direction, and if so, report how far it could move and the surface normal where they would touch.

So how would that be implemented, or at least how is it called, so I could search for hints?

\$\endgroup\$
1
\$\begingroup\$

If your 2D convex polygons are defined by an array of 2D Vectors then you are looking for line-line intersection or edge-edge intersection, whichever you prefer.

This stackoverflow page has an advanced and precise algorith: https://stackoverflow.com/questions/2255842/detecting-coincident-subset-of-two-coincident-line-segments/2255848#2255848

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.