This function calculates the distance between a 2D or 3D line and one or more points.
You can input either a 2D or a 3D line and 2D or 3D points. This function is an extended version of the line below, with some input checking:
distance=norm(cross(v1-v2,pt-v2))/norm(v1-v2)
Licence: CC by-nc-sa 4.0