powered by
This function calculates the shortest distance between a point and a line segment in 2D space.
distancePointSegment(x, y, x1, y1, x2, y2)
x-coordinate of point
y-coordinate of point
x-coordinate of one endpoint of the line segment
y-coordinate of line segment endpoint with x-coordinate x1
x-coordinate of other endpoint of line segment
y-coordinate of line segment endpoint with x-coordinate x2
# NOT RUN { distancePointSegment(0, 0, -1, 1, 1, -1) # }
Run the code above in your browser using DataLab