Пример #1
0
def make_bisector_to_pair_map(points):
    pairs = form_pairs(points)
    result = dict()
    for pair in pairs:
        bisector = perpendicular_bisector(pair[0], pair[1])
        result[bisector] = pair
    return result
Пример #2
0
def find_constrained_redundant_points(lst, line):
    pairs = form_pairs(lst)
    critical_points = list()
    critpnt_to_pair_map = dict()
    rejected_points = list()
    for pair in pairs:
        intersection = pair_bisector_and_line_intersection(pair[0], pair[1], line)
        if intersection is None:
            closest = min(pair, key=lambda p: abs(line.distance_to_point(p)))
            rejected_points.append(closest)
        else:
            critical_points.append(intersection)
            critpnt_to_pair_map[intersection] = pair

    #
    # for now we just handle a single point situation which is the most common
    # and natural one. for further consideration try to find all points whose
    # distance to the median point is ~(far-med) distance.
    #

    med = median_along_line(critical_points, line)
    far = max(lst, key=lambda p: med.sub(p).squared_norm())
    med_val = line.direction_value_on_point(med)
    far_val = line.direction_value_on_point(far)

    if is_constrained_pointer_centre_found(med_val, far_val):
        # the centre is found. need to handle
        pass

    suspicious_pnts = suspicious_points(critical_points, med_val, far_val, line)

    for x in suspicious_pnts:
        pair = critpnt_to_pair_map[x]
        bisector = perpendicular_bisector(pair[0], pair[1])
        med_sign = bisector.distance_to_point(med)
        if med_sign * bisector.distance_to_point(pair[0]) > 0:
            rejected_points.append(pair[0])
        elif med_sign * bisector.distance_to_point(pair[1]) > 0:
            rejected_points.append(pair[1])
        else:
            print med_sign, bisector.distance_to_point(pair[0]), bisector.distance_to_point(pair[1])
            assert False
    
    return rejected_points
Пример #3
0
def find_constrained_centre_directly(lst, line):
        smallest_circle = None
        pivot_points = list()
        for p in lst:
            projection = point_to_line_projection(p, line)
            assert line.is_point_on_line(projection)
            smallest_circle, pivot_points = check_smaller_circle(smallest_circle,
                                                                 lst, pivot_points, [p],
                                                                 func=construct_circle_with_centre_and_point,
                                                                 args=[projection, p])
            for q in lst:
                if p is not q:
                    bisector = perpendicular_bisector(p, q)
                    intersection = bisector.intersection(line)
                    if intersection is not None:
                        smallest_circle, pivot_points = check_smaller_circle(smallest_circle,
                                                                             lst, pivot_points, [p, q],
                                                                             func=construct_circle_with_centre_and_point,
                                                                             args=[intersection, p])

        return smallest_circle, pivot_points
def reduced_circle_new(point1, point2, line):
    result = perpendicular_bisector(point1, point2).intersection(line)
    if result is None:
        raise ValueError("Cannot reduce circle")
    return MyCircle(result, result.sub(point1).norm())
Пример #5
0
def pair_bisector_and_line_intersection(point1, point2, line):
    bisector = perpendicular_bisector(point1, point2)
    return bisector.intersection(line)