for n in range(polygon.get_length()):
        # line_temp = polygon[n].find_line_point_to_point(polygon[n + 1])
        # distance.append(point_test, line_temp)
        print(ref_point[n], ref_point[n+1])
        point_obstacle = closest_point_to_line(point_test, polygon.poly[ref_point[n]], polygon.poly[ref_point[n + 1]])
        if point_test.find_distance_between_points(point_obstacle) < distance:
            distance = point_test.find_distance_between_points(point_obstacle)
            closest_point_on_obstacle.x = point_obstacle.x
            closest_point_on_obstacle.y = point_obstacle.y
    return closest_point_on_obstacle


def attraction_force(point_to_test, point_goal):
    vector_magnitude = point_to_test.find_distance_between_points(point_goal)
    attraction_vector = Point(point_goal.x - point_to_test.x, point_goal.y - point_to_test.y)
    attraction_vector.scale_point(ATTRACTION_COEFFICIENT / vector_magnitude)
    return attraction_vector


def repulsive_force(point_to_test, point_obstacle, polygon_centroid):
    distance_to_obstacle = point_to_test.find_distance_between_points(point_obstacle)
    distance_to_center = point_to_test.find_distance_between_points(polygon_centroid)
    repulsive_vector = Point(0, 0)
    abs_distance = distance_to_center - distance_to_obstacle
    if distance_to_center <= REPULSIVE_RANGE:
        repulsive_magnitude = (0.5*REPULSIVE_COEFFICIENT)*(1/(distance_to_center-3)**2)
        # *(1/abs_distance**2)
        vector_magnitude = point_to_test.find_distance_between_points(polygon_centroid)
        repulsive_vector.set_x((point_to_test.x - polygon_centroid.x) * repulsive_magnitude / vector_magnitude)
        repulsive_vector.set_y((point_to_test.y - polygon_centroid.y) * repulsive_magnitude / vector_magnitude)