Distance between point and line🔗

Calculates the shortest distance between a line and a point or a set of points.

Inputs🔗

  • line: Line as a 2×2 matrix containing two points on the line as rows.

  • points: The coordinates of a point or many points as an N-by-2 matrix.

Outputs🔗

  • distances: The distances between the points and an infinite line that goes through the two points. An N-by-1 matrix. If the start and end points in the line input are the same, distance will be NaN.