Say I have a method of calculating the minimum distance between two finite line segments in three-dimensional space. How might I adapt this method to provide the minimum distance between the surfaces of two hollow tubes of radii $R_1$ & $R_2$ and respective lengths $L_1$ & $L_2$?
At the limit of having long hollow tubes, where the point of closest approach is near their respective mid-points, the simpler line segment to line segment distance suffices. However, how does one handle the case where the tubes fail to have the same slope and the point of closest approach is near one or the other tube's end?
Note - There are no circular 'end-caps' on the tubes referenced in this problem.
For each tube, its point of closest approach can be on its curved surface, or on one of its two rims -- three possibilities. So there are nine possibilities for the two tubes combined. I think the simplest solution is to try all nine (rejecting curved-surface solutions that are off the end of the tube) and pick the smallest. For this you need three different algorithms:
As far as I can see, none of these is made easier by knowing the distance between two finite line segments.
Edited to add: I just realised that Algorithm 3 must return all local minima (there may be two of them), in case the global minimum is off the end of the tube.