def lin_interp(oldpos, newpos, oldtow, newtow, triggertow):
    """
    Linearly interpolates distance.
    Interpolation accurate to the mm.

    Parameters
    ----------
    o : integer
      distance previous to trigger
    n : integer
      distance prior to trigger
    oldtow : integer
      TOW of data packet previous to trigger
    newtow : integer
      TOW of data packet after trigger
    triggertow : integer
      TOW of trigger
    """
    if not oldtow < triggertow < newtow:
        print('TOW values ERROR at {0}'.format(triggertow))
    if newtow - oldtow > 3000:
        print('Interpolation end-points for Trigger at TOW {0} too far away'
            .format(triggertow))
    d = float(newpos - oldpos)
    t = newtow - oldtow
    v = d / t
    return oldpos + v * (triggertow - oldtow)
