How to calculate line line intersection

The question was also asked and answered on the Slicer forum: