I’m doing GJK + EPA in 2D for collision detection + resolution.
For GJK, I was using the vector (1,0) as my first support direction. However, if the origin happens to fall exactly on the simplex line ( quite easily happens with circles placed on an axis-aligned plane), inside EPA, it doesn’t know which direction to expand to. That is because the expansion is supposed to happen in the direction of origin. But because the origin is on the line, the vector towards origin has a length of 0. So although collision is detected in GJK, I don’t get any contact normal + penetration depth from EPA.
I’ve ‘solved’ it by randomizing the initial support direction every time. It can still miss a few times in a second but the visual result looks fine.
Is there a standard way of handling this edge case that I don’t know of? Or maybe this shouldn’t be happening at all and I’m doing something wrong?