This question already has an answer here:
- Closest points on two line segments 2 answers
The answer for the shortest distance between two skew lines has already been answered here and is also found on Wikipedia.
However, I need to apply a further constraint. I need to find the shortest distance between two skew line segments. Or, if it is easier, two rays, whose starting points are $P_1$ and $P_2$. How can I modify the equations for $c_1$ and $c_2$ in the wiki link to account for this? Or is this a far more complicated problem?