def get_corner_point(points, x_factor, y_factor):
    """
    Fetches the point furthest in the given direction out of the collection of points.
    Internally, fetches the item with the largest value of p[0][0]*x_factor + p[0][1]*y_factor
    :param points: The collection to search in. This should be in the format produced by cv2.approxPolyDP,
    a numpy array of shape [n, 1, 2] (where n is the number of points)
    :param x_factor: Which side the point should be on horizontally: -1 = left, 1 = right, 0 = no preference
    :param y_factor: Which side the point should be on vertically: -1 = top, 1 = bottom, 0 = no preference
    :return:
    """
    return max(points, key=lambda p: x_factor * p[0][0] + y_factor * p[0][1])