def perpendicular_segment(self, p):
        p = Point(p)
        if p in self:
            return p
        a, b, c = self.coefficients
        if a == 0:  # horizontal
            p2 = Point(p.x, self.p1.y)
        elif b == 0:  # vertical
            p2 = Point(self.p1.x, p.y)
        else:
            # ax + by + c = 0
            y = (-c - a*p.x)/b
            m = self.slope
            d2 = 1 + m**2
            H = p.y - y
            dx = m*H/d2
            dy = m*dx
            p2 = (p.x + dx, y + dy)
        return Segment(p, p2)
Create a perpendicular line segment from `p` to this line.
dataset/ETHPy150Open sympy/sympy/sympy/geometry/line.py/LinearEntity.perpendicular_segment