mirror of
https://github.com/BelfrySCAD/BOSL2.git
synced 2024-12-29 16:29:40 +00:00
Tweaks to deal with some coner case
This commit is contained in:
parent
83f7ec499e
commit
fee433f654
1 changed files with 4 additions and 5 deletions
|
@ -2423,9 +2423,7 @@ function _GJK_distance(points1, points2, eps=EPSILON, lbd, d, simplex=[]) =
|
||||||
lbd = max(lbd, d*v/nrd), // distance lower bound
|
lbd = max(lbd, d*v/nrd), // distance lower bound
|
||||||
close = (nrd-lbd <= eps*nrd)
|
close = (nrd-lbd <= eps*nrd)
|
||||||
)
|
)
|
||||||
// v already in the simplex is a degenerence due to numerical errors
|
close ? d :
|
||||||
// and may produce a non-stopping loop
|
|
||||||
close || [for(nv=norm(v), s=simplex) if(norm(s-v)<=eps*nv) 1]!=[] ? d :
|
|
||||||
let( newsplx = _closest_simplex(concat(simplex,[v]),eps) )
|
let( newsplx = _closest_simplex(concat(simplex,[v]),eps) )
|
||||||
_GJK_distance(points1, points2, eps, lbd, newsplx[0], newsplx[1]);
|
_GJK_distance(points1, points2, eps, lbd, newsplx[0], newsplx[1]);
|
||||||
|
|
||||||
|
@ -2480,9 +2478,10 @@ function convex_collision(points1, points2, eps=EPSILON) =
|
||||||
// http://www.dtecta.com/papers/jgt98convex.pdf
|
// http://www.dtecta.com/papers/jgt98convex.pdf
|
||||||
function _GJK_collide(points1, points2, d, simplex, eps=EPSILON) =
|
function _GJK_collide(points1, points2, d, simplex, eps=EPSILON) =
|
||||||
norm(d) < eps ? true : // does collide
|
norm(d) < eps ? true : // does collide
|
||||||
let( v = _support_diff(points1,points2,-d) )
|
let( v = _support_diff(points1,points2,-d) )
|
||||||
v*d > eps ? false : // no collision
|
v*d > eps*eps ? false : // no collision
|
||||||
let( newsplx = _closest_simplex(concat(simplex,[v]),eps) )
|
let( newsplx = _closest_simplex(concat(simplex,[v]),eps) )
|
||||||
|
norm(v-newsplx[0])<eps ? norm(v)<eps :
|
||||||
_GJK_collide(points1, points2, newsplx[0], newsplx[1], eps);
|
_GJK_collide(points1, points2, newsplx[0], newsplx[1], eps);
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue