Shortest distance between two line segments
This is my solution in Python. Works with 3d points and you can simplify for 2d. import numpy as np def closestDistanceBetweenLines(a0,a1,b0,b1,clampAll=False,clampA0=False,clampA1=False,clampB0=False,clampB1=False): ”’ Given two lines defined by numpy.array pairs (a0,a1,b0,b1) Return the closest points on each segment and their distance ”’ # If clampAll=True, set all clamps to True if clampAll: clampA0=True clampA1=True clampB0=True … Read more