'Are two linear entities perpendicular?
Parameters
l1 : LinearEntity
l2 : LinearEntity
Returns
True : if l1 and l2 are perpendicular,
False : otherwise.
See Also
coefficients
Examples
>>> from sympy import Point, Line
>>> p1, p2, p3 = Point(0, 0), Point(1, 1), Point(-1, 1)
>>> l1, l2 = Line(p1, p2), Line(p1, p3)
>>> l1.is_perpendicular(l2)
True
>>> p4 = Point(5, 3)
>>> l3 = Line(p1, p4)
>>> l1.is_perpendicular(l3)
False
>>> from sympy import Point3D, Line3D
>>> p1, p2, p3 = Point3D(0, 0, 0), Point3D(1, 1, 1), Point3D(-1, 2, 0)
>>> l1, l2 = Line3D(p1, p2), Line3D(p2, p3)
>>> l1.is_perpendicular(l2)
False
>>> p4 = Point3D(5, 3, 7)
>>> l3 = Line3D(p1, p4)
>>> l1.is_perpendicular(l3)
False'

def is_perpendicular(l1, l2):

    if ((not isinstance(l1, LinearEntity)) and (not isinstance(l2, LinearEntity))):
        raise TypeError('Must    pass    only    LinearEntity    objects')
    return S.Zero.equals(l1.direction.dot(l2.direction))
