title: How to calculate the closest point onto an edge segment in C++ and GLM?
body: <p>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. </p>
  
  <p>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.</p>
  
  <p>Here is a diagram to illustrate my problem. </p>
  
  <p><a href="https://i.stack.imgur.com/SN22R.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/SN22R.jpg" alt="enter image description here"></a></p>
  
  <p>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.</p>
  
  <p>Thanks!</p>