def test_simple_example1(): problem = create_problem() target = create_target(problem) solver = Solver(problem) solver.add_target(target) problem = solver.solve() assert problem.entity.find_child('AEB', type_=Angle).angle == 75
def test_vertical_angle(): problem = create_problem() target = create_target(problem) solver = Solver(problem) solver.add_target(target) problem = solver.solve() assert problem.entity.find_child('COD').angle == 40
def test_supplementary_angle(): problem = create_problem() target = create_target(problem) solver = Solver(problem) solver.add_target(target) problem = solver.solve() assert problem.entity.find_child('CBD').angle == 130
def test_common_vertex_angle_relationship(): problem = create_problem() target = create_target(problem) solver = Solver(problem) solver.add_target(target) problem = solver.solve() assert problem.entity.find_child('BAD').angle == 70
def test_collineation_relationship_reduction(): problem = create_problem() target = create_target(problem) solver = Solver(problem) solver.add_target(target) problem = solver.solve() assert problem.entity.find_child('AC').length == 3
def test_parallel(): problem = create_problem() target = create_target(problem) solver = Solver(problem) solver.add_target(target) problem = solver.solve() assert problem.entity.find_child('AEC').angle == 30
def test_triangle_angle_reduction(): problem = create_problem() target = create_target(problem) solver = Solver(problem) solver.add_target(target) problem = solver.solve() assert problem.entity.find_child('BAC', Angle).angle == 60
def test_perpendicular(): problem = create_problem() target = create_target(problem) solver = Solver(problem) solver.add_target(target) problem = solver.solve() assert problem.entity.find_child('BEC').angle == 90
def test_simple_example4(): problem = create_problem() target = create_target(problem) solver = Solver(problem) solver.add_target(target) problem = solver.solve() assert round(problem.entity.find_child('MN', type_=Line).length, 6) == 2.4
def test_similar_triangle(): problem = create_problem() target = create_target(problem) solver = Solver(problem) solver.add_target(target) problem = solver.solve() assert abs(problem.entity.find_child('EF', Line).length - 2) < 0.000001
def test_simple_example2(): problem = create_problem() target = create_target(problem) solver = Solver(problem) solver.add_target(target) problem = solver.solve() assert problem.entity.find_child( 'DE', type_=Line).length - (3**(1 / 2) / 2) * 210 < 0.00001
def test_simple_example(): problem = create_problem() target1 = create_target1(problem) target2 = create_target2(problem) solver = Solver(problem) solver.add_target(target1) solver.add_target(target2) problem = solver.solve() assert problem.entity.find_child('CFE', type_=Angle).angle == 75 assert problem.entity.find_child('BDC', type_=Angle).angle == 65
def parse(self): problem = self.get_problem() solver = Solver(problem) print('Create a triangle successfully!') print(problem) # Add targets. for id_, type_, attr in self._target_dict: target = Target(TargetType.EVALUATION, entity=problem.entity.find_child(id_, type_), attr=attr) solver.add_target(target) solver.solve() return problem