Finds the segment of a line nearest to a point