def bear(a1, b1, a2, b2):
<EOL>tol = <NUM_LIT><EOL>v1 = CartesianVector.from_spherical(<NUM_LIT:1.0>, a1, b1)<EOL>v2 = CartesianVector.from_spherical(<NUM_LIT:1.0>, a2, b2)<EOL>v0 = CartesianVector.from_spherical(r=<NUM_LIT:1.0>, alpha=<NUM_LIT:0.0>, delta=d2r(<NUM_LIT>))<EOL>if abs(v1.cross(v0).mod) < tol:<EOL><INDENT>warnings.warn(<EOL>"<STR_LIT>")<EOL>return <NUM_LIT:0.0><EOL><DEDENT>v12 = v1.cross(v2)<EOL>v10 = v1.cross(v0)<EOL>dot = v12.dot(v10)<EOL>cross = v12.cross(v10).mod<EOL>x = math.atan2(cross, dot)<EOL>if v12.z < <NUM_LIT:0>:<EOL><INDENT>x = -x<EOL><DEDENT>if abs(x) < tol:<EOL><INDENT>return <NUM_LIT:0.0><EOL><DEDENT>else:<EOL><INDENT>return x<EOL><DEDENT>
Find bearing/position angle between two points on a unit sphere.

    Parameters
    ----------
    a1, b1 : float
        Longitude-like and latitude-like angles defining the first
        point. Both are in radians.

    a2, b2 : float
        Longitude-like and latitude-like angles defining the second
        point. Both are in radians.

    Notes
    -----
    Position angle of the second point with respect to the first
    is returned in radians. Position angle is calculated clockwise
    and counter-clockwise from the direction towards the North
    pole. It is between [0 and π] if the second point is in the
    eastern hemisphere w.r.t the first, and between (0, -π) if
    the second point is in the western hemisphere w.r.t the first.

    .. warning::

        If the first point is at the pole then bearing is undefined and
        0 is returned.

    Results agree with those from SLALIB rountine sla_dbear. See
    test_bear_against_slalib_dbear() in test_angles.py.

    Examples
    --------
    >>> from angles import bear, r2d, d2r
    >>> bear(0, 0, 0, -d2r(90.0))
    3.141592653589793
    >>> bear(0, -d2r(90.0), 0, 0)
    0.0
    >>> bear(0, -d2r(45.0), 0, 0)
    0.0
    >>> bear(0, -d2r(89.678), 0, 0)
    0.0

    >>> r2d(bear(d2r(45.0), d2r(45.0), d2r(46.0), d2r(45.0)))
    89.64644212193384

    >>> r2d(bear(d2r(45.0), d2r(45.0), d2r(44.0), d2r(45.0)))
    -89.64644212193421