I'm developing a 3d collision pipeline in C++ using OpenGL and GLM, however I cannot seem to figure out a formula for calculating the closest point (the player origin) to a triangle's edge segment.
For example, say you have vertex "A" and vertex "B" constructing the edge, point "C" representing the player origin and "D" being the closest point from "C" to the edge. How would one go about calculating this? I understand that by getting the cross product of (b - a) and (c - a) can help with edge alignment, however I need to get the coordinate in 3D Cartesian space, not a comparison.
Here is a diagram to illustrate my problem.
I need to find "Point on edge". Example code in the form of GLM or similar would be much appreciated! This question differs to the original as this refers to the C++ language and GLM library for vector math.
Thanks!