ClosestLinePoints
From Solid Graphics Wiki

The ClosestLinePoints function calculates positions and coordinates of closest points of two lines.
void ClosestLinePoints ( const float P0[ 3 ], const float P1[ 3 ], const float Q0[ 3 ], const float Q1[ 3 ], float *s, float *t = NULL, float PC[ 3 ] = NULL, float QC[ 3 ] = NULL );
void ClosestLinePoints ( const double P0[ 3 ], const double P1[ 3 ], const double Q0[ 3 ], const double Q1[ 3 ], double *s, double *t = NULL, double PC[ 3 ] = NULL, double QC[ 3 ] = NULL );
Parameters
P0  x,y,z coordinates of first point defining the first line 
P1  x,y,z coordinates of second point defining the first line 
Q0  x,y,z coordinates of first point defining the second line 
Q1  x,y,z coordinates of second point defining the second line 
s  the function will store into variable pointed by s position of closest point lying on the first line. The line position can be then translated to point coordinates using the LinePositionToPoint function. 
t  if the parameter is not NULL then the function will store into variable pointed by t position of closest point lying on the second line. 
PC  if the parameter is not NULL then the function will store into variable pointed by PC coordinates of the closest point lying on the first line. 
QC  if the parameter is not NULL then the function will store into variable pointed by QC coordinates of the closest point lying on the second line. 
See Also