Distance between a point and a triangle in 3D
Updated 14 Oct 2010
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.
Gwendolyn Fischer (2023). Distance between a point and a triangle in 3D (https://www.mathworks.com/matlabcentral/fileexchange/22857-distance-between-a-point-and-a-triangle-in-3d), MATLAB Central File Exchange. Retrieved .
MATLAB Release Compatibility
Platform CompatibilityWindows macOS Linux
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!Start Hunting!
Discover Live Editor
Create scripts with code, output, and formatted text in a single executable document.