Introduction - If you have any usage issues, please Google them yourself
Calculate the distance of a given point P from a triangle TRI. Point P is a row vector of the form 1x3. The triangle is a matrix formed by three rows of points TRI = [P1 P2 P3] each of size 1x3. dist = pointTriangleDistance(TRI,P) returns the distance of the point P to the triangle TRI. [dist,PP0] = pointTriangleDistance(TRI,P) additionally returns the closest point PP0 to P on the triangle TRI