I am going to calculate the shortest distance from a point to a triangle(3d). I have projected the point to the plane of the triangle and than taken the barycentric coordinates of the projection of the point. But i could not find a way to clamp the coordinates to always be inside the triangle.
when searching I've only found the 0 <= [u,v,w] and u+v+w = 1. but how would this be solved?
You can't clamp a point to a triangle that way if you want to find the shortest distance from a point to a triangle. Distance is in Cartesian space, whereas barycentric coordinates are not.
In order to determine the distance of a point to a triangle that is outside the triangle, you need to determine which feature of the triangle the point is closest to (line segment, or corner), then the distance to that feature. Clamping barycentric coordinates in any way that does not take into account the transformation back to Cartesian space will simply not work.