def _IntegrateTime(self, new_pos, log=False):
    """Integrates time by movement along the linear path defined by the
    vector between self._last_pos and new_pos.

    - 'm': slope of line from self._last_pos to new_pos.
    - 'a': max rate of change (self._roc_max) is (max - min seconds) / screen height
    - 'b': rate of change slope (self._roc_slope)
    - 'c': last Y position (self._last_pos[1])
    - 'd': exponent in an inverse exponential curve from max roc to min roc
    """
    x_delta = float(new_pos[0] - self._last_pos[0])
    y_delta = (new_pos[1] - self._last_pos[1])
    if y_delta == 0.0:
      return 0.0  # no integration necessary
    m = x_delta / y_delta
    a = self._roc_max
    b = self._roc_slope
    c = float(self._last_pos[1])

    def _ComputeIntegral(y):
      return 0.5 * y * (2*a + b*(2*self._last_pos[0] + m*(y-2*self._last_pos[1])))

    if log:
      max_diff = (new_pos[1] - self._last_pos[1]) * (self._roc_max + self._roc_slope * min(new_pos[0], self._last_pos[0]))
      print 'max interval: %.2f' % (self._max_time - self._min_time)
      print 'x delta: %.2f, y delta: %.2f, slope: %.2f' % (x_delta, y_delta, 1/m)
      print 'max difference allowed: %.2f' % max_diff
      print 'integral at new pos: %.2f' % _ComputeIntegral(new_pos[1])
      print 'integral at old pos: %.2f' % _ComputeIntegral(self._last_pos[1])
      print 'integrated difference: %.2f' % (_ComputeIntegral(new_pos[1]) - _ComputeIntegral(self._last_pos[1]))

    return _ComputeIntegral(new_pos[1]) - _ComputeIntegral(self._last_pos[1])
dataset/ETHPy150Open viewfinderco/viewfinder/clients/experimental/viewfinder.py/VFTime._IntegrateTime/original