コード例 #1
0
def question_22_17(query):
    VertexB = Point(Fraction(1), Fraction(-2), "B")
    VertexC = Point(Fraction(-2), Fraction(-1), "C")
    EdgeA = Line.get_line_contains_points(VertexB, VertexC)
    p1 = Point(Fraction(2), Fraction(0), "p1")
    p2 = Point(Fraction(2), Fraction(1), "p2")
    EdgeC = Line.get_line_contains_points(VertexB, p1)
    EdgeB = Line.get_line_contains_points(VertexC, p2)
    del p1, p2

    BisectorAngleA = Line.get_bisectors_for_2lines(EdgeB, EdgeC)[0]
    VertexOfTargetRhombusInsideEdgeA = EdgeA.get_cross_point(BisectorAngleA)

    EageOfTargetRhombusParallelsToEdgeC = Line.get_line_parallel_to(EdgeC, VertexOfTargetRhombusInsideEdgeA)
    EageOfTargetRhombusParallelsToEdgeB = Line.get_line_parallel_to(EdgeB, VertexOfTargetRhombusInsideEdgeA)
    VertexOfTargetRhombusInsideEdgeB = Line.get_cross_point(EageOfTargetRhombusParallelsToEdgeC, EdgeB)
    VertexOfTargetRhombusInsideEdgeC = Line.get_cross_point(EageOfTargetRhombusParallelsToEdgeB, EdgeC)

    TriangleEdges = {(EdgeA.a, EdgeA.b, EdgeA.c), (EdgeB.a, EdgeB.b, EdgeB.c), (EdgeC.a, EdgeC.b, EdgeC.c)}
    init_figure, grid_size = common.INIT_FIGURE(), common.GRID_SIZE()
    init_figure.extend(TriangleEdges)

    resolution_vertex_in_edge_a = query.query_point_by_symmetry(VertexOfTargetRhombusInsideEdgeA, init_figure)
    resolution_vertex_in_edge_b = query.query_point_by_symmetry(VertexOfTargetRhombusInsideEdgeB, init_figure)
    resolution_vertex_in_edge_c = query.query_point_by_symmetry(VertexOfTargetRhombusInsideEdgeC, init_figure)

    resolution_product = itertools.product(resolution_vertex_in_edge_a,
                                           resolution_vertex_in_edge_b,
                                           resolution_vertex_in_edge_c)
    solution_for_all = [frozenset((set(r[0]) | set(r[1]) | set(r[2]))) for r in resolution_product]
    solution_for_all.sort()

    targets = (VertexOfTargetRhombusInsideEdgeA, VertexOfTargetRhombusInsideEdgeB, VertexOfTargetRhombusInsideEdgeC)
    for r in solution_for_all:
        draw_resolution(r, targets, init_figure, grid_size)
コード例 #2
0
def question_27_14(query):
    total = []
    total.append(centroid_of_2x2_grid(-2, +2, (True, True, True, False)))
    total.append(centroid_of_2x2_grid(+2, +2, (True, True, False, True)))
    total.append(centroid_of_2x2_grid(-2, -2, (True, False, True, True)))
    total.append(centroid_of_2x2_grid(+2, -2, (True, True, True, False)))
    x, y, w = centroid_of_iter(total)
    point_target = Point(x, y, "Target")
    solution = query.query_point_by_symmetry(point_target)
    init_figure, grid_size = common.INIT_FIGURE(), common.GRID_SIZE()
    for r in solution:
        draw_resolution(r, [point_target], init_figure, grid_size)
コード例 #3
0
def question_27_15(query):
    total = []
    total.append((Fraction(-1.5), Fraction(1.5), 4))  # top-left
    total.append((2, Fraction(1.5), 4))  # top-right

    total.append((centroid_of_2x2_grid(-2, -2, (False, True, True, True))))  # bottom-left -very left
    total.append((centroid_of_2x2_grid(0, -2, (False, False, True, False))))  # bottom-left -right part

    total.append((2, -2, 4))  # bottom-right
    x, y, w = centroid_of_iter(total)
    point_target = Point(x, y, "Target")
    solution = query.query_point_by_symmetry(point_target)
    init_figure, grid_size = common.INIT_FIGURE(), common.GRID_SIZE()
    for r in solution:
        draw_resolution(r, [point_target], init_figure, grid_size)
コード例 #4
0
def question_16_15(query):
    line1 = Line.get_line_contains_points(Point(-2, 0), Point(0, 1))
    line2 = Line.get_line_contains_points(Point(0, -1), Point(1, 1))
    line = Line.get_bisectors_for_2lines(line1, line2)[0]
    A = line1.get_cross_point(line2)

    # query and show it(them)
    init_figure, grid_size = common.INIT_FIGURE(), common.GRID_SIZE()
    init_figure.extend(((line1.a, line1.b, line1.c), (line2.a, line2.b, line2.c)))
    solution = query.query_line_by_symmetry(line, (A,), init_figure)

    points = set([s[0] for s in solution])
    for r in solution[:4]:
        p, fig = r
        draw_resolution(fig, points, init_figure, grid_size)
コード例 #5
0
def question_24_6(query):
    A = Point(1, -2)
    B = Point(0, 1)
    line1 = Line.get_line_contains_points(A, B)
    line2 = Line.get_line_by_point_slope(A, Fraction(4))

    tan_alpha = Fraction(1, 4)
    tan_beta = Fraction(1, 3)
    tan_theta = tan_of_add(tan_of_double(tan_beta), tan_alpha)
    slope = tan_of_neg(tan_of_complementary(tan_theta))

    line = Line.get_line_by_point_slope(A, slope)
    # query and show it(them)
    init_figure, grid_size = common.INIT_FIGURE(), common.GRID_SIZE()
    init_figure.extend(((line1.a, line1.b, line1.c), (line2.a, line2.b, line2.c)))
    solution = query.query_line_by_symmetry(line, (A,), init_figure)

    points = set([s[0] for s in solution])
    for r in solution[:4]:
        p, fig = r
        draw_resolution(fig, points, init_figure, grid_size)
コード例 #6
0
def question_14_8(query):
    # get Point B
    line1 = Line.get_line_contains_points(Point(-3, -1), Point(3, -3))
    line_tmp = Line(1, 0, -2)
    B = line1.get_cross_point(line_tmp)

    # get Point A
    line2 = Line.get_line_contains_points(Point(-3, 1), Point(2, 2))
    line_tmp = Line(1, 0, 1)
    A = line2.get_cross_point(line_tmp)
    line = Line.get_line_contains_points(A, B)

    point_target = A.middle(B)

    # query and show it(them)
    init_figure, grid_size = common.INIT_FIGURE(), common.GRID_SIZE()
    for ll in (line, line1, line2):
        init_figure.append((ll.a, ll.b, ll.c))
    solution = query.query_point_by_symmetry(point_target, init_figure)
    for r in solution[:4]:
        draw_resolution(r, [point_target], init_figure, grid_size)
コード例 #7
0
def question_14_9(query):
    # get Point B
    line1 = Line.get_line_contains_points(Point(-3, 1), Point(3, 3))
    line2 = Line(1, 0, -2)
    B = line1.get_cross_point(line2)
    # get Point A
    line1 = Line.get_line_contains_points(Point(2, -3), Point(3, 0))
    line2 = Line(0, 1, -1)
    A = line1.get_cross_point(line2)
    del line1, line2

    # get the midpoint
    target_point_x = (A.x + B.x) / 2
    target_point_y = (A.y + B.y) / 2
    point_target = Point(target_point_x, target_point_y, "Target")

    # query and show it(them)
    solution = query.query_point_by_symmetry(point_target)
    init_figure, grid_size = common.INIT_FIGURE(), common.GRID_SIZE()
    for r in solution:
        draw_resolution(r, [point_target], init_figure, grid_size)
コード例 #8
0
def question_24_7(query):
    A = Point(2, -1)
    B = Point(-2, 0)
    line1 = Line.get_line_contains_points(A, B)
    line2 = Line.get_line_by_point_slope(A, Fraction(-1))

    tan_alpha = Fraction(1, 4)
    tan_beta = tan_of_sub(Fraction(1), tan_alpha)
    tan_theta = tan_of_sub(tan_beta, tan_alpha)
    slope = tan_theta

    line = Line.get_line_by_point_slope(A, slope)
    # query and show it(them)
    init_figure, grid_size = common.INIT_FIGURE(), common.GRID_SIZE()
    init_figure.extend(((line1.a, line1.b, line1.c), (line2.a, line2.b, line2.c)))
    solution = query.query_line_by_symmetry(line, (A,), init_figure)

    points = set([s[0] for s in solution])

    for r in solution[:4]:
        p, fig = r
        draw_resolution(fig, points, init_figure, grid_size)
コード例 #9
0
def get_pythagorea_graph():
    point_tab = bfs_dump_for_pythagorea(common.INIT_FIGURE(),
                                        common.GRID_SIZE(), 3)
    return point_tab