input: Write a function to determine the shortest path between two points in a matrix using BFS algorithm. The function should return the length of the shortest path. If no path exists, it should return `math.inf`.
  
  assert shortest_path([[2, 3, 5], [1, 7, 6], [3, 0, 9]], (0, 0), (2, 2)) == 5
  assert shortest_path([[2, 3, 5], [1, 7, 6], [3, 0, 9]], (0, 0), (1, 2)) == 4
  assert shortest_path([[2, 3, 5], [1, 7, 6], [3, 0, 9]], (0, 0), (2, 0)) == 3
  assert shortest_path([[2, 3, 5], [1, 7, 6], [3, 0, 9]], (0, 0), (0, 2)) == 3
  assert shortest_path([[2, 3, 5], [1, 7, 6], [3, 0, 9]], (0, 0), (0, 1)) == 2
output: import math
  
  def shortest_path(matrix, start, end):
      rows, cols = len(matrix), len(matrix[0])
      directions = [(0, 1), (1, 0), (0, -1), (-1, 0)]
      queue = [(start[0], start[1], 0)]
      visited = set()
      visited.add(start)
      
      while queue:
          x, y, dist = queue.pop(0)
          
          if (x, y) == end:
              return dist
          
          for dx, dy in directions:
              nx, ny = x + dx, y + dy
              if 0 <= nx < rows and 0 <= ny < cols and (nx, ny) not in visited:
                  visited.add((nx, ny))
                  queue.append((nx, ny, dist + 1))
      
      return math.inf