import math


def get_distance_and_angle(index, goal_index, width):
  """ Function to calculate distance and angle """
  index_x = index % width
  index_y = int(index // width)
  goal_x = goal_index % width
  goal_y = int(goal_index // width)

  dx = goal_x - index_x
  dy = goal_y - index_y

  distance = dx ** 2 + dy ** 2
  angle = math.atan2(dy, dx)
  return math.sqrt(distance), angle