DISTANCEPOINTTRIANGLE3D Minimum distance between a 3D point and a 3D triangle.
DIST = distancePointTriangle3d(PT, TRI);
Computes the minimum distance between the point PT and the triangle
TRI. The Point PT is given as a row vector of three coordinates. The
triangle TRI is given as a 3-by-3 array containing the coordinates of
each vertex in a row of the array:
TRI = [...
X1 Y1 Z1;...
X2 Y2 Z2;...
X3 Y3 Z3];
[DIST, PROJ] = distancePointTriangle3d(PT, TRI);
Also returns the coordinates of the projeced point.
Example
tri = [1 0 0; 0 1 0;0 0 1];
pt = [0 0 0];
dist = distancePointTriangle3d(pt, tri)
dist =
0.5774
See also
meshes3d, distancePointMesh, distancePointEdge3d, distancePointPlane
Reference
* David Eberly (1999), "Distance Between Point and Triangle in 3D"
https://www.geometrictools.com/Documentation/DistancePoint3Triangle3.pdf
* see Distance between a point and a triangle in 3d, by Gwendolyn Fischer.
(same algorithm, but different order of input argument)
* https://fr.mathworks.com/matlabcentral/fileexchange/22857-distance-between-a-point-and-a-triangle-in-3d
Package: matgeom