import math


def dp(
    emission1: float,
    gndaz1: float,
    emission2: float,
    gndaz2: float,
    radar=False,
):
    """Returns the Parallax/Height Ratio (dp) as detailed in
    Becker et al.(2015).

    The input angles are assumed to be in radians.  If *radar* is true,
    then cot() is substituted for tan() in the calculations.

    Physically, dp represents the amount of parallax difference
    that would be measured between an object in the two images, for
    unit height.
    """

    def emission_trig(emi: float):
        e = math.tan(emi)
        if radar:
            # Cotangent is 1 / tan()
            return 1 / e
        else:
            return e

    def px(emi: float, scazgnd: float):
        return -1 * emission_trig(emi) * math.cos(scazgnd)

    def py(emi: float, scazgnd: float):
        return emission_trig(emi) * math.sin(scazgnd)

    px1 = px(emission1, gndaz1)
    px2 = px(emission2, gndaz2)
    py1 = py(emission1, gndaz1)
    py2 = py(emission2, gndaz2)

    return math.sqrt(math.pow(px1 - px2, 2) + math.pow(py1 - py2, 2))