Is SAT's Minimum Translation Vector always correct and precise in all instances? I calculate it by iterating over all the possible axes and check for overlap on each then keep tracking of which axis has the shortest overlap and using that as the penetration vector.
As you can see, some calculations for the Minimum Translation Vector aren't always right.
In this short extract, I find the penetration vector and I would like you guys to help me discover what is wrong:
direction = Vector.Sub(me.Verts[k-1], me.Verts[k])
axis = Vector.Normalize(Vector.Perp(direction))
min_1, max_1 = Vector.Project(me, axis)
min_2, max_2 = Vector.Project(ent, axis)
if (max_1 < min_2 or max_2 < min_1) == False:
if ((max_2 - min_1) or (max_1 - min_2)) < first_separation[0]:
if max_2 - min_1 < max_1 - min_2:
first_separation = [max_2 - min_1, axis]
else:
first_separation = [max_1 - min_2, axis]
Elsewhere, I use the following line of code to get my vector value:
separator, axis = first_separation
vec = [axis[0] * (separator * -1), axis[1] * separator * -1]
According to this blog link: Collision Detection Using the Separating Axis Theorem, the SAT works fine on triangles, IF you calculate all 3 normals of each triangle. I don't see that in your code. I think you may have implemented some invalid short cuts in your version of the SAT.