SquareOfLineSegmentsDistance
From Solid Graphics Wiki

The SquareOfLineSegmentsDistance function returns square of shortest distance between two line segments.
float SquareOfLineSegmentsDistance ( const float P0[ 3 ], const float P1[ 3 ], const float Q0[ 3 ], const float Q1[ 3 ], float C[ 3 ] );
double SquareOfLineSegmentsDistance ( const double P0[ 3 ], const double P1[ 3 ], const double Q0[ 3 ], const double Q1[ 3 ], double C[ 3 ] );
Parameters
P0  x,y,z coordinates of first point defining the first line segment 
P1  x,y,z coordinates of second point defining the first line segment 
Q0  x,y,z coordinates of first point defining the second line segment 
Q1  x,y,z coordinates of second point defining the second line segment 
C  the function stores x,y,z coordinates of the closest point from the first line segment to the variable pointed by C 
Return Value
The square of shortest distance of the two line segments.
See Also