'The smallest of the two angles formed at the
intersection of two linear entities.
Parameters
l1 : LinearEntity
l2 : LinearEntity
Returns
angle : angle in radians
Notes
From the dot product of vectors v1 and v2 it is known that:
``dot(v1, v2) = |v1|*|v2|*cos(A)``
where A is the angle formed between the two vectors. We can
get the directional vectors of the two lines and readily
find the angle between the two using the above formula.
See Also
is_perpendicular, Ray2D.closing_angle
Examples
>>> from sympy import Point, Line
>>> p1, p2, p3 = Point(0, 0), Point(0, 4), Point(2, 0)
>>> l1, l2 = Line(p1, p2), Line(p1, p3)
>>> l1.angle_between(l2)
pi/2
>>> 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.angle_between(l2)
acos(-sqrt(2)/3)'

def angle_between(l1, l2):

    if ((not isinstance(l1, LinearEntity)) and (not isinstance(l2, LinearEntity))):
        raise TypeError('Must    pass    only    LinearEntity    objects')
    (v1, v2) = (l1.direction, l2.direction)
    return acos((v1.dot(v2) / (abs(v1) * abs(v2))))
