def get_line_from_two_points(p1, p2):
  """
  Returns a function which takes
  an x-coordinate and returns the
  corresponding y-coordinate on the
  line defined by the points p1, p2

  """
  slope = p2[1] - p1[1]
  slope /= p2[0] - p1[0]
  return lambda x: (slope * (x - p1[0])) + p1[1]