from scipy import reciprocal
from math import hypot

class Point:
    def __init__(self, x, y):
        self.x = x
        self.y = y

class LineSegment:
    def __init__(self, a, b):
        self.a = a
        self.b = b

def distance_from_line_segment():
    Lx1 = -6.0
    Ly1 = 0.0

    Lx2 = 3.0
    Ly2 = 3.0

    # the slope
    Lk = (Ly1 - Ly2) / (Lx1 - Lx2)
    print(Lk)

    # point
    Px = -12.0
    Py = 0.0

    # intersect line
    iLk = - reciprocal(Lk)
    print(iLk)
    # get y on intersect point
    iLy2 = -((iLk * (Px)) - Py)
    print(iLy2)
    # get x on line where iLy2
    iLx2 = Lx1 + (Lx2 - Lx1) * ((iLy2 - Ly1)/(Ly2 - Ly1))
    print(iLx2)

    # distance between intescection point and main point
    dist = hypot(Px - iLx2, Py - iLy2)
    print(dist)

distance_from_line_segment()
0.3333333333333333
-3.0
-36.0
-114.0
108.16653826391968