def line_coeff_from_endpoints(p1, p2):
    """Given two points on a line, find the coefficients of the line
    equation ax + by + c = 0"""
    a = p1.y - p2.y
    b = p2.x - p1.x
    c = -a * p1.x - b * p1.y
    return a, b, c