Some unclear thoughts about sphere-triangle interaction dectection

Submitted by alberthappy on Fri, 03/04/2016 - 17:42

All,

I got some question when I was trying to figure out what kind of algorithm is used in LIGGGHTS to detect sphere and triangle surface interaction. So guys, please help to clear my mind on this problem. In the TriMesh::resolveTriSphereContactBary, I saw this two lines:

vectorSubtract3D(cSphere,n[0],node0ToSphereCenter); //double **n = node_(nTri);
MathExtraLiggghts::calcBaryTriCoords(node0ToSphereCenter,edgeVec(nTri),edgeLen(nTri),bary);

The first line is to calculate the vector from the first node point of the triangle to the sphere center. The second line tries to calculate the barycentric coordinates of the sphere center on the triangle plane? But the problem is that the sphere center is not necessary on the triangle plane. In my mind, if you want to determine the interaction between sphere and triangle, first you need to find the closest point on the triangle plane to the sphere center (projection of sphere center point on the plane), then you can determine the barycentric coordinates of the closest point in the frame of the triangle edge vector. But I did not see any lines doing the projection of sphere center to the triangle plane in TriMesh::resolveTriSphereContactBary. My question is: can you directly use calcBaryTriCoords function to determine the barycentric coordinates of sphere center point on the triangle plane? I did not find any material giving this algorithm.

Best Regards,

Fenglei

medvedeg | Mon, 03/07/2016 - 12:34

Dear alberthappy,

this method for calculation of the barycentric coordinates will give the same answer as if you project the sphere center onto the triangle plane and calculated. See the book "Real-time collision detection" (2005, pp. 47-48) by C.Ericson for more details on the method.

Best wishes

Alexander Podlozhnyuk