Developing function to calculate shortest distance between a set of points and the vertices of a line