313bool btVoronoiSimplexSolver::closestPtPointTriangle(
const btVector3& p,
const btVector3& a,
const btVector3&
b,
const btVector3& c,
btSubSimplexClosestResult& result)
315 result.m_usedVertices.reset();
318 btVector3 ab =
b - a;
319 btVector3 ac = c - a;
320 btVector3 ap = p - a;
325 result.m_closestPointOnSimplex = a;
326 result.m_usedVertices.usedVertexA =
true;
327 result.setBarycentricCoordinates(1, 0, 0);
332 btVector3 bp = p -
b;
335 if (d3 >=
btScalar(0.0) && d4 <= d3)
337 result.m_closestPointOnSimplex =
b;
338 result.m_usedVertices.usedVertexB =
true;
339 result.setBarycentricCoordinates(0, 1, 0);
348 result.m_closestPointOnSimplex = a +
v * ab;
349 result.m_usedVertices.usedVertexA =
true;
350 result.m_usedVertices.usedVertexB =
true;
351 result.setBarycentricCoordinates(1 -
v,
v, 0);
357 btVector3 cp = p - c;
360 if (d6 >=
btScalar(0.0) && d5 <= d6)
362 result.m_closestPointOnSimplex = c;
363 result.m_usedVertices.usedVertexC =
true;
364 result.setBarycentricCoordinates(0, 0, 1);
373 result.m_closestPointOnSimplex = a +
w * ac;
374 result.m_usedVertices.usedVertexA =
true;
375 result.m_usedVertices.usedVertexC =
true;
376 result.setBarycentricCoordinates(1 -
w, 0,
w);
385 btScalar w = (d4 - d3) / ((d4 - d3) + (d5 - d6));
387 result.m_closestPointOnSimplex =
b +
w * (c -
b);
388 result.m_usedVertices.usedVertexB =
true;
389 result.m_usedVertices.usedVertexC =
true;
390 result.setBarycentricCoordinates(0, 1 -
w,
w);
400 result.m_closestPointOnSimplex = a + ab *
v + ac *
w;
401 result.m_usedVertices.usedVertexA =
true;
402 result.m_usedVertices.usedVertexB =
true;
403 result.m_usedVertices.usedVertexC =
true;
404 result.setBarycentricCoordinates(1 -
v -
w,
v,
w);
437bool btVoronoiSimplexSolver::closestPtPointTetrahedron(
const btVector3& p,
const btVector3& a,
const btVector3&
b,
const btVector3& c,
const btVector3& d,
btSubSimplexClosestResult& finalResult)
454 if (pointOutsideABC < 0 || pointOutsideACD < 0 || pointOutsideADB < 0 || pointOutsideBDC < 0)
460 if (!pointOutsideABC && !pointOutsideACD && !pointOutsideADB && !pointOutsideBDC)
474 if (sqDist < bestSqDist)
499 if (sqDist < bestSqDist)
524 if (sqDist < bestSqDist)
548 if (sqDist < bestSqDist)
bool closestPtPointTetrahedron(const btVector3 &p, const btVector3 &a, const btVector3 &b, const btVector3 &c, const btVector3 &d, btSubSimplexClosestResult &finalResult)
int pointOutsideOfPlane(const btVector3 &p, const btVector3 &a, const btVector3 &b, const btVector3 &c, const btVector3 &d)
Test if point p and d lie on opposite sides of plane through abc.