I have a set of segments (not lines), (A1, B1) , (A2, B2) , (A3, B3) , where A , B are the end points of the line segment. Each A and B has (x,y) coordinates.
Question: I need to know the shortest distance between point O and line segments , as shown in the figure. implemented in the line of codes. The code I can really understand is either pseudo code or Python.
CODE: I tried to solve the problem with this code, unfortunately, it does not work properly.
def dist(A, B, O): A_ = complex(*A) B_ = complex(*B) O_= complex(*O) OA = O_ - A_ OB = O_ - B_ return min(OA, OB)

Thanks in advance.
python numpy intersection euclidean distance
Spider
source share