unit4_pp/scripts/unit4_exercise_solution.py
def create_new_branch_point(p1, p2, max_distance):
  """
  Creates a new point at the max_distance towards a second point
  p1: the point to go from (as a list containing x and y values)
  p2: the point to go to (as a list containing x and y values)
  max_distance: the expand distance (in grid cells)
  returns: new point as a list containing x and y values
  """
  new_point = list(p1)
  d = calculate_distance(new_point, p2)
  theta = calculate_angle(new_point, p2)

  # if distance to closest node is less than the maximum branch lenght
  if max_distance > d:
      max_distance = d

  new_point[0] += int(max_distance * cos(theta))
  new_point[1] += int(max_distance * sin(theta))

  return new_point

  Creates a new point at the max_distance towards a second point
  p1: the point to go from (as a list containing x and y values)
  p2: the point to go to (as a list containing x and y values)
  max_distance: the expand distance (in grid cells)
  returns: new point as a list containing x and y values
  
Creates a new point at the max_distance towards a second point
p1: the point to go from (as a list containing x and y values)
p2: the point to go to (as a list containing x and y values)
max_distance: the expand distance (in grid cells)
returns: new point as a list containing x and y values
Creates a new point at the max_distance towards a second point p1 : the point to go from ( as a list containing x and y values ) p2 : the point to go to ( as a list containing x and y values ) max_distance : the expand distance ( in grid cells ) returns : new point as a list containing x and y values
def create_new_branch_point(p1, p2, max_distance):
  new_point = list(p1)
  d = calculate_distance(new_point, p2)
  theta = calculate_angle(new_point, p2)
  if max_distance > d:
      max_distance = d
  new_point[0] += int(max_distance * cos(theta))
  new_point[1] += int(max_distance * sin(theta))
  return new_point
def create_new_branch_point ( p1 , p2 , max_distance ) : new_point = list ( p1 ) d = calculate_distance ( new_point , p2 ) theta = calculate_angle ( new_point , p2 ) if max_distance > d : max_distance = d new_point [ 0 ] += int ( max_distance * cos ( theta ) ) new_point [ 1 ] += int ( max_distance * sin ( theta ) ) return new_point
Creates a new point at the max_distance towards a second point
p1: the point to go from (as a list containing x and y values)
p2: the point to go to (as a list containing x and y values)
max_distance: the expand distance (in grid cells)
returns: new point as a list containing x and y values
Creates a new point at the max_distance towards a second point p1 : the point to go from ( as a list containing x and y values ) p2 : the point to go to ( as a list containing x and y values ) max_distance : the expand distance ( in grid cells ) returns : new point as a list containing x and y values
"""
  Creates a new point at the max_distance towards a second point
  p1: the point to go from (as a list containing x and y values)
  p2: the point to go to (as a list containing x and y values)
  max_distance: the expand distance (in grid cells)
  returns: new point as a list containing x and y values
  """ # if distance to closest node is less than the maximum branch lenght
p1
p2
max_distance