def interpolate(r1, r2, x=None, y=None):
    """Perform simple linear interpolation between two points in 2D
      - one of x or y must be defined

    Parameters
    ----------

    r1,r2 : float
      x,y coordinates from which to interpolate

    x : float
      x-value from which to interpolate y (default: None)

    y : float
      y-value from which to interpolate x (default: None)

    Returns
    -------

    val : float
      interpolated value

    History

    2019 - Written - Webb (UofT)

    """
    x1, y1 = r1
    x2, y2 = r2

    m = (y2 - y1) / (x2 - x1)
    b = y1 - m * x1

    if x != None:
        val= m * x + b
    elif y != None:
        val=(y - b) / m
    else:
        print("NO INTERMEDIATE COORDINATE GIVEN")
        val=0

    return val