closestPoint(const SGVec3<T>& p, const SGTriangle<T>& tri)
{ return closestPoint(tri, p); }
closestPoint(const SGVec3<T>& p, const SGTriangle<T>& tri)
{ return closestPoint(tri, p); }
{
// This method minimizes the distance function Q(u, v) = || p - x ||
// where x is a point in the trialgle given by the vertices v_i
{
// This method minimizes the distance function Q(u, v) = || p - x ||
// where x is a point in the trialgle given by the vertices v_i
// The theoretical analysis is somehow too long for a comment.
// May be it is sufficient to see that this code passes all the tests.
// The theoretical analysis is somehow too long for a comment.
// May be it is sufficient to see that this code passes all the tests.
T baseDist2 = dot(off, off);
T a = dot(tri.getEdge(0), tri.getEdge(0));
T b = dot(tri.getEdge(0), tri.getEdge(1));
T baseDist2 = dot(off, off);
T a = dot(tri.getEdge(0), tri.getEdge(0));
T b = dot(tri.getEdge(0), tri.getEdge(1));