def twit_interp(range_start: int, range_end: int, value_start: float, value_end: float, idx: int) -> float:
    """
    Return the interpolated value from value_start to value_end along range at idx as a float. Range is a two entry
    tuple of float or integer. If range_start equals range_end then returns value_start.  Both or either of range and
    v1 to v2 can be negative distances. Does not check that idx is in the range.  In which case it can return values
    outside the v[0] to v[1] range. Range and idx do not have to be integers.
    """
    rspan = range_end - range_start
    if rspan == 0:
        return value_start
    return value_start + (value_end - value_start) * (idx - range_start) / rspan