①: If two graphs are in contact, then the EPA will get an embedding vector of 0 vectors. As long as the original point just on the Minkowski boundary of the situation also ruled out as a non-contact can be solved.
②: If the origin falls exactly on the simplex ab edge, then the search direction will be 0 vectors, and the resulting simplex is no longer a triangle, but a line segment. At this point only to determine whether overlapping GJK can still be judged normally, but then the EPA will not work properly. The personal solution is to forcibly use AB's vertical vector as the search direction to find a point C to form a triangle. The subsequent EPA may have a slightly biased embedding vector, but it is still within the accepted range.
Isintersect:function () {var dir = new Pngx. VECTOR2D (1, 1), Simplexa, Simplexb, Simplexc; Simplexa = This.getsupportpoint (dir); if (Simplexa.dot (dir) <= 0) {return false; dir = Simplexa.negate (); Simplexb = This.getsupportpoint (dir); if (Simplexb.dot (dir) <= 0) {return false; } var ab = Simplexb.sub (simplexa); dir = Pngx. Vector2d.tripleproduct (AB, Simplexa.negate (), AB); for (var i = this.maxiterations; i--;) {if (Dir.iszero ()) {this._simplexa = Simplexa; This._simplexb = Simplexb; dir = simplexb.sub (simplexa). Vertical (); This._simplexc = This.getsupportpoint (dir); The origin is exactly on the AB to make the search direction is 0 vectors, forcibly select a perpendicular to the direction of AB to find SimplThe 3rd return of ex is true; } Simplexc = This.getsupportpoint (dir); if (Simplexc.dot (dir) <= 0) {//less than sign to less than equals, the origin is exactly on the boundary and also excludes return false; } var ba = Simplexa.sub (SIMPLEXB), ac = Simplexc.sub (Simplexa), BC = Simplexc.sub (SIMPLEXB), Acperp = Pngx. Vector2d.tripleproduct (AC, Ba.negate (), ac), Bcperp = Pngx. Vector2d.tripleproduct (BC, BA, BC); if (Acperp.dot (Simplexa) > 0) {simplexb = Simplexc; dir = Acperp.negate (); } else if (Bcperp.dot (SIMPLEXB) > 0) {simplexa = Simplexc; dir = Bcperp.negate (); } else {this._simplexa = Simplexa; This._simplexb = Simplexb; This._simplexc = Simplexc; return true; }} return false; }
Two pits of the GJK