def common_vertex_angle_sum(common_vertex_angle: CommonVertexAngle,
                            finder: Finder) -> None:
    lines = common_vertex_angle.lines
    num_lines = len(lines)

    for i in range(num_lines):
        for j in range(i + 1, num_lines):
            for k in range(j + 1, num_lines):
                angle_ij = finder.find_angle_by_sides(lines[i], lines[j])
                angle_jk = finder.find_angle_by_sides(lines[j], lines[k])
                angle_ik = finder.find_angle_by_sides(lines[i], lines[k])
                yield symbol(angle_ij, 'angle') \
                    + symbol(angle_jk, 'angle') \
                    - symbol(angle_ik, 'angle')
def n_angle_sector_ratio(n_angle_sector: NAngleSector, finder: Finder) -> None:
    angle = n_angle_sector.angle
    line = n_angle_sector.line
    ratio = n_angle_sector.ratio
    nearer_line = n_angle_sector.nearer_line
    if nearer_line is None:
        nearer_line = angle.sides[0]
    angle_mid = finder.find_angle_by_sides(line, nearer_line)
    yield symbol(angle, 'angle') * ratio - symbol(angle_mid, 'angle')
def _get_angles_fixed_ends(col1: Collineation, col2: Collineation, end1: Point,
                           end2: Point, finder: Finder):
    for top_p in col1.points:
        if top_p == end1:
            continue
        for bottom_p in col2.points:
            if bottom_p == end2:
                continue
            top_line = finder.find_line_by_ends(end1, top_p)
            middle_line = finder.find_line_by_ends(top_p, bottom_p)
            bottom_line = finder.find_line_by_ends(bottom_p, end2)
            # print('top line=============', top_line)
            # print('middle line============', middle_line)
            # print('bottom line============', bottom_line)
            if top_line is None \
                    or middle_line is None \
                    or bottom_line is None:
                continue
            top_angle = finder.find_angle_by_sides(top_line, middle_line)
            bottom_angle = finder.find_angle_by_sides(bottom_line, middle_line)
            # print('top angle==============', top_angle)
            # print('bottom angle==============', bottom_angle)
            if top_angle is not None and bottom_angle is not None:
                yield top_angle, bottom_angle
Ejemplo n.º 4
0
def perpendicular_angle(perpendicular: Perpendicular,
                       finder: Finder) -> None:
    line1 = perpendicular.line1
    line2 = perpendicular.line2
    # Extend line first.
    line1 = finder.extend_line(line1)
    line2 = finder.extend_line(line2)
    # Find intersection.
    intersection = finder.find_lines_intersection(line1, line2)
    if len(intersection) != 1:
        raise Exception('Perpendicular relationship is suppposed to include '
                        'two perpendicular line. Except 1, got {}.'
                        .format(len(intersection)))
    cross_p = intersection[0]
    for p1 in line1.ends:
        for p2 in line2.ends:
            if p1 == cross_p or p2 == cross_p:
                continue
            line1_ = finder.find_line_by_ends(p1, cross_p)
            line2_ = finder.find_line_by_ends(p2, cross_p)
            angle = finder.find_angle_by_sides(line1_, line2_)
            yield symbol(angle, 'angle') - 90