There's a great many articles on finding the intersecting of a ray and a triangle, or the closest point on a triangle to some other point. However, I can't find anything for finding the closest points between a ray and a triangle.
Perhaps a bit more formally, given the triangle defined by points A, B, and C, and a ray defined by an origin O and a direction D, find the two points P and Q where P is on the ray, Q is on the triangle, and the distance between P and Q is minimal.
I've tried to start with editing a ray-triangle intersection algorithm, but I don't think that's going to work. A lot of them seem to find where the ray intersects with the plane defined by the triangle, but that's not necessarily the closest point (imagine a ray that is mostly parallel to the plane and slightly above it - the closest point on the ray would be above the triangle, not intersecting its plane).
Has anyone developed an algorithm for this, and if so, what is it?
Putting together some stuff from this question's comments:
If the ray is facing away from the triangle (i.e. the ray's time-of-intersection with the plane defined by the triangle is negative, which most ray-triangle intersections test for), the closest point on the ray is the ray's origin. Can use that point with a standard algorithm to find the corresponding closest point on the triangle.(For lines parallel to the triangle, there may not be a singular closest point, but that does not matter for my case in particular)