def IsPointApproxOnLine(point, line, tolerance=1):
  """Approximates distance between point and line for small distances using
  the determinant and checks whether it's within the tolerance. Tolerance is
  an approximate distance in pixels, precision decreases with distance."""
  xd = line[0] - line[2]
  yd = line[1] - line[3]
  det = ((xd) * (point[1] - line[3])) - ((yd) * (point[0] - line[2]))
  tolerance = float(tolerance) * (abs(xd) + abs(yd))
  return abs(det) * 2.0 <= tolerance