def bresenham(p0, p1):
  """
    Bresenham's line algorithm is a line drawing algorithm that determines the
    points of an n-dimensional raster that should be selected in order to form
    a close approximation to a straight line between two points. It is commonly
    used to draw line primitives in a bitmap image (e.g. on a computer screen),
    as it uses only integer addition, subtraction and bit shifting, all of
    which are very cheap operations in standard computer architectures.

    Args:

      p0 (np.array): Starting point (x, y)
      p1 (np.array): End point (x, y)

    Returns:

      A list of (x, y) intermediate points from p0 to p1.

  """
  x0, y0 = p0
  x1, y1 = p1
  dx = abs(x1 - x0)
  dy = abs(y1 - y0)
  sx = 1.0 if x0 < x1 else -1.0
  sy = 1.0 if y0 < y1 else -1.0
  err = dx - dy

  line = []
  while True:
    line.append([x0, y0])
    if x0 == x1 and y0 == y1:
      return line

    e2 = 2 * err
    if e2 > -dy:
      # overshot in the y direction
      err = err - dy
      x0 = x0 + sx
    if e2 < dx:
      # overshot in the x direction
      err = err + dx
      y0 = y0 + sy